<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Apr 19, 2017, at 12:10 PM, Paweł Wojtkowiak via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">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</span></div></blockquote></div><div class=""><br class=""></div><div class="">You don't even really have *that* option for mutating operations. There, you'd need to do something like: </div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func withMutable<T, Result>(_ value: inout T, do body: (inout T) throws -> Result) rethrows -> Result {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>return try body(&value)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>withMutable(&classA.structB.stringC) { c in</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>c[c.startIndex..<i] = …</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; border-spacing: 0px;"><div class=""><div style="font-size: 12px; " class="">-- </div><div style="font-size: 12px; " class="">Brent Royal-Gordon</div><div style="font-size: 12px; " class="">Architechies</div></div></span>
</div>
<br class=""></body></html>