scala def 定义函数的区别
1 | def foo = {1} |
A function which should return a non-Unit value must be declared with the = notation (although of course the compiler can infer the return-type from the expression’s type).
1 | def foo {1} |
返回类型为Unit
In Scala if a method declaration does not have an equal sign before its body, the compiler infers that the result type will be Unit