[swift-evolution] [swift-evolution-announce] [Review] SE-0173: Add `MutableCollection.swap(_:with:)
Howard Lovatt
howard.lovatt at gmail.com
Wed Apr 26 22:48:22 CDT 2017
I use:
(b, a) = (a, b)
So I wouldn't miss it.
On Thu, 27 Apr 2017 at 9:33 am, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> On Wed, Apr 26, 2017 at 6:02 PM, Howard Lovatt <howard.lovatt at gmail.com>
> wrote:
>
>> Regarding: "Source compatibility is a serious goal now. There's no harm
>> in the current `swap`, and I use it. This is no rationale for breaking
>> existing code."
>>
>> Swap for arrays will have to go when ARC controls come in. You can't pass
>> two parts of the same array to one function. The relevant bit from the
>> Ownership manifesto is:
>>
>> "Accessing a component of a value type through a subscript is treated as
>> accessing the entire value, and so is considered to overlap any other
>> access to the value."
>>
>
> Yes, for arrays. I use it to swap two variables `a` and `b`.
>
> ```
> var a = 1
> var b = 2
> swap(&a, &b)
> ```
>
> --
-- Howard.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170427/573a0398/attachment.html>
More information about the swift-evolution
mailing list