<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>I cannot remember any use of such a feature but instead of a language feature there is also a reasonable library solution:</div><div><br></div><div>// inspired by the lens idea (of Joe Groff I think)</div><div>// there is probably a better name</div><div>func lens<T>(value: T, lensClosure: inout T -> ()) -> T {</div><div> var value = value</div><div> lensClosure(&value)</div><div> return value</div><div>}</div><div><br></div><div>// usage</div><div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">let john = (firstName:"John", lastName:"Doe")<br>let alice = lens(john) { $0.firstName = "Alice" }</span></font></div></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">Kind regards</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">- Maximilian</span></font></div><div><br>Am 23.03.2016 um 09:06 schrieb Zsolt Szatmári via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br><br></div><blockquote type="cite"><div>Dear All,<div><div><br></div><div> The only thing I am really missing right now from Swift is described as following. This works in some other languages, e.g. F#, Kotlin, and Haskell.</div><div><br></div><div> F# example (taken from <a href="https://fsharpforfunandprofit.com/posts/correctness-immutability/">https://fsharpforfunandprofit.com/posts/correctness-immutability/</a>)</div><div> </div><div>let john = {firstName="John"; lastName="Doe"}</div><div>let alice = {john with FirstName="Alice"}</div><div><br></div><div> Current way to do this in Swift is:</div><div> </div>let john = (firstName:"John", lastName:"Doe")<br>var alice = john<br>alice.firstName = "Alice"<br><div class="nylas-n1-signature"><div><br></div><div> This might seem to be a nuance, but it's more cumbersome (especially if one wants to do this frequently), and we are left with a var at the end.</div><div> Also, this idea rhymes with the current direction of removing var arguments from functions.</div><div> What do You think? Thank You.</div><div><br></div><div>Zsolt</div><div><br></div></div></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>