java和scala调用函数的区别
1 | object.method(); |
在scala中,这样调用,don’t need the semi-colon:
1 | object.method() |
甚至都不用括号(and then you can omit the parentheses):
1 | object.method |
如果方法只有一个参数,
1 | object.method(param) |
你可以把点换成空格,而且可以把括号去掉(you can change the Scala syntax to use a space instead of a dot, while also dropping the parentheses):
1 | object method param |
Scala methods that take a single parameter can be invoked without dots or parentheses.