[Swift-devel] New syntax for appending to arrays

Mihael Hategan hategan at mcs.anl.gov
Wed Jun 29 15:18:29 CDT 2011


On Thu, 2011-06-30 at 00:19 +0530, Yadu Nand wrote:

> I am having some issue with array appends in nested loops. I'm pasting
> the code here, I have attached the output, logs and kml generated.
> Any help will be appreciated.
> 
> int array[ ][ ];
> foreach dummy in [1:2] {
>         array["key"] += 1;
>         array["key"] += 2;
>         foreach v in array["key"]{
>         trace (v);
>         }
> }
> 

So you are appending 1 and 2 twice, which should give you [1, 2, 1, 2].
And then you are printing that array twice, so you should have 8 lines
of output from trace. Which checks out.

And then the consumer inside the producer loop, I don't think that the
compiler flow detector can deal with that, but that's another issue.




More information about the Swift-devel mailing list