The current proposal for Map.update() tests to see if the key exists in the map; if it doesn't, and you didn't pass a default-value thunk, it throws.
I think this should instead just pass undefined to the update function. This matches the current philosophy behind Map.get(), which purposely does not throw when the key doesn't exist. If we ever extend Map.get() to have a default-value thunk as well, then calling m.get("doesn't exist") wont' suddenly start throwing; it'll just continue returning undefined as today, and .update() should do the same.
I don't want to have to write a no-op _=>{} just to avoid errors when I don't care about them. ^_^
The current proposal for Map.update() tests to see if the key exists in the map; if it doesn't, and you didn't pass a default-value thunk, it throws.
I think this should instead just pass
undefined
to the update function. This matches the current philosophy behindMap.get()
, which purposely does not throw when the key doesn't exist. If we ever extendMap.get()
to have a default-value thunk as well, then callingm.get("doesn't exist")
wont' suddenly start throwing; it'll just continue returning undefined as today, and.update()
should do the same.I don't want to have to write a no-op
_=>{}
just to avoid errors when I don't care about them. ^_^