[swift-users] edit array

J.E. Schotsman jeschot at xs4all.nl
Wed Apr 26 11:54:23 CDT 2017

On 26 Apr 2017, at 18:13, Ole Begemann <ole at oleb.net> wrote:

> There have been requests for something like this on swift-evolution, e.g. here in the context of the discussion about a `reduce` variant that takes `inout` arguments: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170123/030641.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170123/030641.html>

Jonathan Hull is indeed asking for the same thing.

> But as far as I know there hasn't been a proposal for adding this. (Is it important enough to have in the standard library? I don't know.)

I do it all the time!

BTW, it seems that the possibility to edit an array in this way isn’t mentioned explicitly anywhere in The Swift Programming Language.

Formally it requires two copies, like

myInstanceCopy = array[index]
myInstanceCopy.field = newValue
array[index] =  myInstanceCopy

Jan E.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170426/e98de052/attachment.html>

More information about the swift-users mailing list