[Swift-devel] New syntax for appending to arrays

Michael Wilde wilde at mcs.anl.gov
Tue Jun 28 09:04:35 CDT 2011


This sound good.  I assume one should be able to append to any dimension of a multi-dimensional array with +=.

int a[][];

a[5] += 1
a[5] += 2

sets a[5][?] = 1
     a[5][?] = 2

where ? is the index values chosen by +=

Further, as you work out the typing rules for array subscripts, should the following work?

int a[][[];
int b[];
b += 100;
b += 200;
a += b;  # <=== should this append a new array to a?

- Mike

----- Original Message -----
> > As proposed earlier, a new syntax for appending values to
> > arrays have been implemented. Examples are given below.
> 
> I think I have been won over to the += syntax.
> 
> > Please note that, we still need to make sure that when we can
> > only append to an array, so to associate keys and multiple
> > values, (i think) we will need two(or more) dimensional arrays.
> 
> yes. but there are already multi-dimensional arrays in swift.
> 
> also, a one dimensional array should still work, like this:
> 
> int a[];
> a += 232;
> a += 111;
> 
> --

-- 
Michael Wilde
Computation Institute, University of Chicago
Mathematics and Computer Science Division
Argonne National Laboratory




More information about the Swift-devel mailing list