As for maps in Scala, if ms - (k, 1, m)
returns a map containing all ms maps except for any comparison with the given keys x, 1 and m.
Then, which operator will return the mapping of all mappings ms with only given keys, x, 1 and m. those. I'm looking for a subset of ms, where only k, 1 and m are keys.
This works, but it's terrible:
scala> val originalMap = Map("age" -> "20", "name" -> "jack", "hobby" -> "jumping") ms: scala.collection.immutable.Map[java.lang.String,java.lang.String] = Map(age -> 20, name -> jack, hobby -> jumping) scala> val interestingKeys = List("name", "hobby") interesting: List[java.lang.String] = List(name, hobby) scala> val notInterestingMap = originalMap -- interestingKeys notInterestingMap: scala.collection.immutable.Map[java.lang.String,java.lang.String] = Map(age -> 20) scala> val interestingMap = originalMap -- notInterestingMap.keySet interestingMap: scala.collection.immutable.Map[java.lang.String,java.lang.String] = Map(name -> jack, hobby -> jumping)
source share