[swift-evolution] << Operator to append to array

Paul Ossenbruggen possen at gmail.com
Mon Dec 21 11:30:14 CST 2015


I should have said 

myArray += [myArrayItem]

> On Dec 21, 2015, at 9:28 AM, Paul Ossenbruggen <possen at gmail.com> wrote:
> 
> You can do this already
> 
> left += [right]
> 
>> On Dec 21, 2015, at 9:22 AM, James Campbell via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> I already have an implementation:
>> 
>> func <<<T>(var left: Array<T>, right:T)
>> 
>> {
>> 
>>     left.append(right)
>> 
>> }
>> 
>> 
>> 
>> It makes
>> 
>> myArray.append(myArrayItem)
>> 
>> become:
>> 
>> myArray << myArrayItem
>> 
>> 
>> 
>> Which is shorter and a lot of languages such as Ruby already use this.
>> 
>> 
>> -- 
>>  Wizard
>> james at supmenow.com <mailto:james at supmenow.com>
>> +44 7523 279 698
>>  _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151221/ef96889b/attachment.html>


More information about the swift-evolution mailing list