map At Replacing Can Destroy
fun A_Map.mapAtReplacingCanDestroy( key: A_BasicObject, notFoundValue: A_BasicObject = nil, canDestroy: Boolean, transformer: (AvailObject, AvailObject) -> A_BasicObject): A_Map
Content copied to clipboard
Look up the key in the map. If present, use the key and the looked up value as arguments to a call to the transformer. Otherwise, use the key and the notFoundValue (nil is default for this) as arguments to the transformer. Store the transformer's result in the map under the key, destroying the original if canDestroy is true. Answer the resulting map.
The map must not change during evaluation of the transformer.
Return
The new map, possibly the mutated original map itself, if canDestroy is true.
Parameters
key
The key to look up.
not Found Value
The value to use as the second argument to the transformer if the key was not found.
can Destroy
Whether the map can be modified by this call, if it's also mutable.
transformer
The binary operator that produces a replacement value to store into the map.