I'm having trouble understanding the difference between / reason for, for example, immutable.Map.transform and immutable.Map.map. It looks like transform won't change the key, but that just seems like a trivial variation of the map method. Am I missing something?
I was expecting to find a method that applied a function to the (key,value) of the map when/if that element was accessed (rather than having to iterate through the map eagerly with the map function). Does such a method exist?
transform
is just a clean way of doingmyMap map { case (k, v) => (k, f(k, v)) }
. About your second question (which seems not closely related to the first one?), are you just looking for something likeupdated
? – Kane May 24 at 20:38