debox icon indicating copy to clipboard operation
debox copied to clipboard

add a Map.put(key: A, value: B): Option[B]

Open performantdata opened this issue 9 years ago • 3 comments

In analogy with mutable.Map. Otherwise one has to search twice, with

val old = m.get(k)
m.update(k, v)
old

which, admittedly, is what MapLike does but isn't efficient.

I can PR such, if you want.

performantdata avatar Sep 08 '15 22:09 performantdata

@performantdata Sounds good. Another one that I think would be nice to have would be some variant of getOrElseUpdate.

non avatar Sep 08 '15 22:09 non

So you want that I write it?

performantdata avatar Sep 08 '15 22:09 performantdata

Feel free to write it if you want. Otherwise, I'll get to it eventually (but maybe not super soon).

non avatar Sep 08 '15 22:09 non