Twitter Scala School , they show a map with a partial function as a value:
// timesTwo() was defined earlier. def timesTwo(i: Int): Int = i * 2 Map("timesTwo" -> timesTwo(_))
If I try to compile this with Scala 2.9.1 and sbt , I get the following:
[error] ... missing parameter type for expanded function ((x$1) => "timesTwo".$minus$greater(timesTwo(x$1))) [error] Map("timesTwo" -> timesTwo(_)) [error] ^ [error] one error found
If I add a parameter type:
Map("timesTwo" -> timesTwo(_: Int))
Then I get the following compiler error:
[error] ... type mismatch; [error] found : Int => (java.lang.String, Int) [error] required: (?, ?) [error] Map("timesTwo" -> timesTwo(_: Int)) [error] ^ [error] one error found
I'm at a dead end. What am I missing?
source share