Re: what is the initial value of arrays of object
bbound@gmail.com wrote:
On Sep 28, 1:36 am, zerg <z...@zerg.org> wrote:
[lots of ideas deleted]
ArrayList literals. Maybe use [{item, item, item}] as the syntax (it
isn't currently legal with some different meaning, so no clash there).
Right now, we have the cumbersome
List<Foo> list = new ArrayList<Foo>();
Collections.addAll(list, item, item, item);
but, not to put too fine a point on it, that freaking blows.
List<Foo> list = [{item, item, item}];
is much nicer.
In between is the currently legal, and barely more complex,
List <Foo> list =
Arrays.asList( { aFoo, anotherFoo, moreFoo, enoughFooAlready } );
That's only thirteen characters longer than your suggestion, or a mere six
with static import:
List <Foo> list = asList( { aFoo, anotherFoo, moreFoo, enoughFooAlready } );
or a mere four with:
List <Foo> list = asList( aFoo, anotherFoo, moreFoo, enoughFooAlready );
and given the simplicity and very explicit self-documenting nature of
'asList', I doubt very much that the language will undergo a change just to
save four characters.
--
Lew