Created
June 17, 2013 15:38
-
-
Save samueltardieu/5797887 to your computer and use it in GitHub Desktop.
Scala seems to always prefer value over call by name: `foo(true)` returns "foo1" and is not ambiguous. Why?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Test { | |
def foo(t: Boolean) = "foo1" | |
def foo(t: => Boolean) = "foo2" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bateast: this doesn't compile for me (2.10.2), none of the two methods is applicable to an argument of type
() => Boolean
, because=> T
isn't a type, and isn't considered like aFunction0[T]
for applicability but like aT
, just a weird, different one...