Here is the code that compiles as intended
def coarse_grained: Int = {
def fib: Int = List(1,2) sum ;
fib
}
def coarse_grained: Int = {
def fib: Int = List(1,2) sum
fib
}
The only difference is ;
after the sum
.
As you know, List(2,6,9).drop(1)
can also be written as List(2,6,9) drop 1
. In fact, it can also be written like this.
List(2,6,9) drop
1
The compiler keeps looking for the final argument, even past a newline. So if you want to do this List(1,2).sum
like this List(1,2) sum
, you'll need to use the semicolon ;
to tell the compiler to stop looking for the final argument. It's not coming.