You wrote foo.add(key, value) instead of foo.add(key) in your API overview.
You wrote "Sets do not have keys so they do not have a .keys()". Actually they do; it's just an alias for .values(). This is so that they provide the same iteration API functions as Maps, which can be useful when writing certain algorithms which will operate on container keys and/or values. Same reason Sets have .entries(). The important difference being that @@iterator maps to Map.entries() but Set.values().
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Some minor corrections:
foo.add(key, value)
instead offoo.add(key)
in your API overview..values()
. This is so that they provide the same iteration API functions as Maps, which can be useful when writing certain algorithms which will operate on container keys and/or values. Same reason Sets have.entries()
. The important difference being that@@iterator
maps toMap.entries()
butSet.values()
.