Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是按预期编译的代码
def coarse_grained: Int = { def fib: Int = List(1,2) sum ; fib }
和一个不
def coarse_grained: Int = { def fib: Int = List(1,2) sum fib }
唯一的区别是;在sum.
;
sum
如你所知,List(2,6,9).drop(1)也可以写成List(2,6,9) drop 1。其实也可以这样写。
List(2,6,9).drop(1)
List(2,6,9) drop 1
编译器一直在寻找最后一个参数,甚至超过一个换行符。所以如果你想这样做List(1,2).sum,List(1,2) sum你需要使用分号;告诉编译器停止寻找最后一个参数。它没有来。
List(1,2).sum
List(1,2) sum