Reputation: 833
In the source, we have elems = toList
.
Why do we need both functions?
Upvotes: 8
Views: 223
Reputation: 53891
It's part of the pattern that most collections provide. In the case of set, there are no keys, so elems = toList
. However with things like a Map
, toList
returns an association list vs elems
which just returns the values.
So the seeming redundancy is to provide a consistent API with other collections like Map
, IntSet
Array
s and IntMap
.
Upvotes: 12