I am trying to filter a map from strings to ints in scala and I am running into a weird issue.
If I put the following into REPL:
scala> val myMap = Map("a" -> 1, "b" -> 2, "c" -> 3)
myMap: scala.collection.immutable.Map[java.lang.String,Int] =
| Map(a -> 1, b -> 2, c -> 3)
It's ok so far, and this works...
scala> myMap.filter(_._2 > 1)
res9: scala.collection.immutable.Map[java.lang.String,Int] = Map(b -> 2, c -> 3)
but this fails...
scala> myMap.filter((k:java.lang.String, v:Int) => v > 1)
<console>:9: error: type mismatch;
found : (java.lang.String, Int) => Boolean
required: ((java.lang.String, Int)) => Boolean
myMap.filter((k:java.lang.String, v:Int) => v > 1)
My question is what is going on with the error message and the extra pair of parentheses? If I try putting in an extra set of parentheses I get error: not a legal formal parameter.