[swift-evolution] [swift-evolution-announce] [Review] SE-0172: One-sided Ranges

Brent Royal-Gordon brent at architechies.com
Wed Apr 19 14:27:51 CDT 2017

> On Apr 19, 2017, at 12:10 PM, Paweł Wojtkowiak via swift-evolution <swift-evolution at swift.org> 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

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

More information about the swift-evolution mailing list