yogendra-aurospaces / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

Creating an empty immutable collection #214

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Do we really want to create the empty Multiset (for example) via 
ImmutableMultiset.of() ??

I would expect there was ImmutableMultiset.empty(), and the of() method was 
defined as of(E, E...) instead of of(E...). The same for the other collection 
types. Having of() in the code with no argument seems peculiar...

Original issue reported on code.google.com by jim.andreou on 28 Jul 2009 at 4:44

GoogleCodeExporter commented 9 years ago
(This is obviously an enhancement, not a defect, sorry)

Original comment by jim.andreou on 28 Jul 2009 at 4:46

GoogleCodeExporter commented 9 years ago
This one's been discussed to death, and it's on me to summarize it all and put 
it in
the FAQ.

ImmutableSet.of() is easier to read when it appears alongside other ImmutableSet
constants which may have one or more elements, and it's easier to deal with 
when code
changes and a formerly-empty set ends up with some elements in it.  Finally, it
doesn't enlarge the surface area of the API.

empty() has its virtues, of course, but we settled on the current solution and 
are
only going to make major changes like this for _really_ compelling reasons now.

Original comment by kevin...@gmail.com on 28 Jul 2009 at 4:51