<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&lt;T&gt;(value: T, lensClosure: inout T -&gt; ()) -&gt; T {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var value = value</div><div>&nbsp; &nbsp; &nbsp; &nbsp; lensClosure(&amp;value)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; 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 &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br><br></div><blockquote type="cite"><div>Dear All,<div><div><br></div><div>&nbsp; The only thing I am really missing right now from Swift is described as following. This works in some other languages, e.g. &nbsp;F#, Kotlin, and Haskell.</div><div><br></div><div>&nbsp; F# example (taken from&nbsp;<a href="https://fsharpforfunandprofit.com/posts/correctness-immutability/">https://fsharpforfunandprofit.com/posts/correctness-immutability/</a>)</div><div>&nbsp;&nbsp;</div><div>let john = {firstName="John"; lastName="Doe"}</div><div>let alice = {john with FirstName="Alice"}</div><div><br></div><div>&nbsp; Current way to do this in Swift is:</div><div>&nbsp;&nbsp;</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>&nbsp; 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>&nbsp; Also, this idea rhymes with the current direction of removing var arguments from functions.</div><div>&nbsp; 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>