Proposal: Collection Literals (original) (raw)

Joshua Bloch jjb at google.com
Tue Mar 31 01:34:28 PDT 2009


Neal,

On Tue, Mar 31, 2009 at 1:16 AM, Neal Gafter <neal at gafter.com> wrote:

How does the syntax distinguish between an initializer for an array of sets, and an initializer for an array of arrays?

Good catch! Of course this is currently legal and must remain so:

Integer[][] aa = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9};

It wouldn't bother me if this were a compiler error:

Set<Integer>[] aa = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

In other words, we could prohibit set literals in array initializers. Arrays of sets are an awful idea anyway, so it's no great loss.

Presumably that would take care of the problem?

Thanks,

Josh


More information about the coin-dev mailing list