Alberto,

I believe your getOrPut methods already exist as putIfAbsent and
computeIfAbsent, unless I'm missing a subtle difference.

On Thu, Oct 16, 2025, 14:20 Alberto Otero Rodríguez <[email protected]>
wrote:

> Also, other two new methods might be interesting if you want to get a
> value from a map, but if the key doesn't exist you want to insert that
> value in the map and return it:
>
> default V getOrPut(Object key, V defaultValue)
>
> default V getOrPut(Object key,  Function<? super K, ? extends V>
> defaultValueFunction)
>

Chris

>

Reply via email to