Proposal: Collection Literals

Vilya Harvey vilya.harvey at gmail.com
Tue Mar 31 00:56:19 PDT 2009


Hi Josh,

This would be a very nice feature to have. One small nit:

By substituting curly braces for the square brackets, you get a set literal
> in place of a list:
>
>
>   final Set<Integer> primes = { 2, 7, 31, 127, 8191, 131071, 524287 };
>

The literal syntax is the same as for an array initialisation, which could
cause a bit of confusion. In the example - for example :-) - it looks like
an array of ints is being autoboxed into a set., but I presume that won't
actually be what happens (i.e. the assignment wouldn't compile if the
literal was replaced by a variable with type int[])?

Vil



More information about the coin-dev mailing list