> On Apr 19, 2017, at 12:10 PM, Paweł Wojtkowiak via swift-evolution 
> <[email protected]> wrote:
> 
> Maybe writing s[s.startIndex..<i] isn't the worst thing, but writing 
> classA.structB.stringC[classA.structB.stringC.startIndex..<i] is not 
> beautiful or easy to read at all, and sometimes it can get really complex. Of 
> course, you can assign these to variables first and then use them


You don't even really have *that* option for mutating operations. There, you'd 
need to do something like: 

        func withMutable<T, Result>(_ value: inout T, do body: (inout T) throws 
-> Result) rethrows -> Result {
                return try body(&value)
        }
        
        withMutable(&classA.structB.stringC) { c in
                c[c.startIndex..<i]  = …
        }

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to