Am Wed, 13 Mar 2013 03:45:20 +0100
schrieb "bearophile" <[email protected]>:

> Marco Leise:
> 
> > But that's probably only because you didn't say:
> >
> >   int[100][3] a2 = [1, 2, 3];
> >
> > :D
> 
> I don't understand.

int[1][3] a2 = [1, 2, 3];

should obviously be rewritten

int[1][3] a2 = [[1], [2], [3]];

but

int[100][3] a2 = [1, 2, 3];

would likely have summoned a controversy about array
initializers with some people finding it reasonable to
do this.
 
> > We should keep _some_ syntax for statically initializing an 
> > array
> > from a single element. It's a far too common task.
> 
> I agree.
> 
> What I have suggested asks to write code like [[1], [2], [3]] 
> instead of [1, 2, 3].
> 
> Bye,
> bearophile

That creates an inconsistency:

// ok, to initialize array of ten with single literal
int[10] a1 = 1;
// not ok, to initialize array of ten with single literal ?
int[10][3] = [1, 2, 3];

-- 
Marco

Reply via email to