[Swift-devel] New syntax for appending to arrays

Jonathan Monette jonmon at utexas.edu
Tue Jun 28 12:35:13 CDT 2011


Ok.  I thought this was a general append where basically you can append anything as long as it had the same type(int, float, string, user definded,...).  That was my confusion.  Thanks.
On Jun 28, 2011, at 12:30 PM, Mihael Hategan wrote:

> On Tue, 2011-06-28 at 12:21 -0500, Jonathan Monette wrote:
>> I guess my question would be what would a look like?  What if this was called.
>> 
>> int a[];
>> int b[];
>> a=[1,2,3];
>> b=[4,5,6];
>> 
>> a+=b;
>> 
>> Saying append makes me think that a+=b would result in something like:
>> 
>> [1,2,3[4,5,6]]
> 
> But a is an array of ints. b is not an int.
> 
>> 
>> Is this the case?  Or would it be [1,2.3,4,5,6].  In python this is called extend while the first is called append.
> 
> No. 
> 
>> 
>> So are we talking about an extend operation or append operation?
> 
> So far we're only talking about:
> t a[]; a += t;
> 
> 




More information about the Swift-devel mailing list