This page is no longer maintained — Please continue to the home page at

Re: higher order functions - compilation question

No replies
Seth Tisue
Joined: 2008-12-16,
User offline. Last seen 34 weeks 3 days ago.

>>>>> "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 © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland