[swift-evolution] Strings in Swift 4
Ted F.A. van Gaalen
tedvgiosdev at gmail.com
Fri Feb 24 17:27:27 CST 2017
ok, I understand, thank you
TedvG
> On 25 Feb 2017, at 00:25, David Sweeris <davesweeris at mac.com> wrote:
>
>
>> On Feb 24, 2017, at 13:41, Ted F.A. van Gaalen <tedvgiosdev at gmail.com> wrote:
>>
>> Hi David & Dave
>>
>> can you explain that in more detail?
>>>> Wouldn’t that turn simple character access into a mutating function?
>>
>> assigning like s[11…14] = str is of course, yes.
>> only then - that is if the character array thus has been changed -
>> it has to update the string in storage, yes.
>>
>> but str = s[n..<m] doesn’t. mutate.
>> so you’d have to maintain keep (private) a isChanged: Bool or bit.
>> a checksum over the character array .
>> ?
>
> It mutates because the String has to instantiate the Array<Character> to which you're indexing into, if it doesn't already exist. It may not make any externally visible changes, but it's still a change.
>
> - Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170225/3f2cb0e1/attachment.html>
More information about the swift-evolution
mailing list