You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 text was updated successfully, but these errors were encountered:
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. ^_^The text was updated successfully, but these errors were encountered: