A useless error message is a known bug in Scala 2.9.
What you need to say:
found : (String, Int) => Boolean required: ((String, Int)) => Boolean
those. you set Function2[String, Int, Boolean] when filter requires Function1[(String, Int), Boolean] .
You can use pattern matching according to tuples, as Nick shows, directly providing a tuple function, as Tomas shows, or you can turn Function2 into Function1 using a tuple using the tupled method:
n.filter(((k: String, v: Int) => !m.contains(k)).tupled) // or n.filter(Function.tupled((k, v) => !m.contains(k)))
But you are best using the built-in filterKeys method:
n.filterKeys(!m.contains(_))
source share