Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map.update() with 2 args shouldn't throw if key doesn't exist in map #35

Open
tabatkins opened this issue Mar 28, 2019 · 0 comments
Open

Comments

@tabatkins
Copy link

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. ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant