Re: higher order functions - compilation question

>>>>> "Vincent" == Vincent G writes:

Vincent> Why does the following code snippet compile with a type
Vincent> mismatch error (found Long, required () => Long)?

Vincent> def foo(f: () => Long) = f
Vincent> def bar: Long = 3
Vincent> foo(bar)

Vincent> To fix it:
Vincent> def bar(): Long = 3

you can also fix it by changing foo(bar) to foo(bar _)

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland