In Twitter's Scala school collections section, 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 the parameter type:
Map("timesTwo" -> timesTwo(_: Int))
I then 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 stumped. What am I missing?