我正在学习scala,无法理解为什么:
def signum(arg: Int) = {
if(arg > 0 ) 1
else if(arg < 0) -1
else 0
}
Run Code Online (Sandbox Code Playgroud)
有Int返回类型signum (arg: Int): Int
但
def signum(arg: Int) = {
if(arg > 0 ) 1
else if(arg < 0) -1
else if(arg == 0) 0
}
Run Code Online (Sandbox Code Playgroud)
具有 AnyVal signum (arg: Int): AnyVal
scala ×1