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

Set is different than Map #73

Closed
marwahaha opened this issue Mar 22, 2019 · 1 comment
Closed

Set is different than Map #73

marwahaha opened this issue Mar 22, 2019 · 1 comment
Assignees
Labels
Misinformation Something isn't correct

Comments

@marwahaha
Copy link
Contributor

I noticed this section of the book

Set and WeakSet
Set and WeakSet are identical to Map, except for 2 major differences:

Instead of .set for values, you use .add() to create a key value pair to store.
All values in a Set must be unique and only occur once.
As far as everything else, they are very identical and are ordered.

If you need a Map-like storage or cache, but all values must be unique, then Set is perfect!

Just like WeakMap, WeakSet allows unused references to be garbage collected, and it cannot be iterated upon.

I think Set is not exactly a key-value store, but just a "value" store.

@MrBenJ
Copy link
Owner

MrBenJ commented Mar 22, 2019

Awesome. This is a really great catch. I'm going to write up something for this section and make a PR for this later sometime.

Thanks for catching this!

@MrBenJ MrBenJ self-assigned this Mar 22, 2019
@MrBenJ MrBenJ added the Misinformation Something isn't correct label Mar 22, 2019
@MrBenJ MrBenJ closed this as completed in 1792919 Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Misinformation Something isn't correct
Projects
None yet
Development

No branches or pull requests

2 participants