First, this:
"1 2".split(" ").toSet
and this:
Set("1", "2")
both evaluate to the same thing, namely
res1: scala.collection.immutable.Set[String] = Set(1, 2)
Why then, when I do:
Set("1", "2") map (_.toInt)
I get as expected this:
res2: scala.collection.immutable.Set[Int] = Set(1, 2)
but when I do this:
"1 2".split(" ").toSet map (_.toInt)
I got:
<console>:12: error: missing parameter type for expanded function ((x$1) => x$1.toInt)
"1 2".split(" ").toSet map (_.toInt)
I checked and additional parentheses do not solve the problem.
The reason in in type inference when using toSet so you need to have a type hint for chain calls or split the calls. You can find details here https://issues.scala-lang.org/browse/SI-7743, https://issues.scala-lang.org/browse/SI-9091