scala - Missing parameter type for expanded function when not assigned to a variable -
this question has answer here:
- type inference fails on set made .toset? 3 answers
i noticed strange behavior of scala compiler. code:
seq("?").toset foreach (println(_))
produces following error:
error: missing parameter type expanded function ((x$1) => println(x$1)) seq("?").toset foreach (println(_)) ^
same happens this:
seq("?").toset foreach (x => println(x))
i found 2 ways around this. ether specify type explicitly:
seq("?").toset[string] foreach (println(_))
or save variable:
val s = seq("?").toset s foreach (println(_))
is reasonable behavior or compiler bug? doesn't make lot of sense me. how explained?
it expands to:
seq("?").toset foreach (println(x=>x))
Comments
Post a Comment