Scala’s MapLike trait has a method
mapValues [C] (f: (B) ⇒ C): Map[A, C]
But I sometimes want a different type:
mapKeysAndValues [C] (f: (A, B) ⇒ C): Map[A, C]
Is there a simple way to do this which I am missing? Of course, this can be done with a fold.
mapmethod iterates though all(key, value)pairs. You can use it like this: