scala 2.9.2
This compiles fine
object AppBuilder extends App {
def app( blockw: Int => String ) : List[String] = List( blockw(6) )
def app( block: => String ) : List[String] = app( _ => block )
}
But in REPL, the same methods/functions ( not sure about the distinction here) as above, when not enclosed in a class, I get the following errors
scala> def app( blockw: Int => String ) : List[String] = List( blockw(6) )
app: (blockw: Int => String)List[String]
scala> def app( block: => String ) : List[String] = app( _ => block )
<console>:8: error: missing parameter type
def app( block: => String ) : List[String] = app( _ => block )
^
Overloaded methods aren’t currently supported in the REPL—see this answer for an explanation of why. You can prove this with a much simpler example:
Now try
f(0), and you’ll get a type mismatch.You can use paste mode as a workaround:
But you’d probably be better off avoiding overloading.