<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="">I think this is the same proposal as this rejected proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0024-optional-value-setter.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0024-optional-value-setter.md</a><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 25 janv. 2017 à 08:56, Sean Heber via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="">Seems trivial to do this now:<br class=""><br class="">var foo = someOptional ?? foo<br class=""><br class="">Unless I’m not understanding?<br class=""><br class="">l8r<br class="">Sean<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Jan 25, 2017, at 10:40 AM, Nichi Shin via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">I’d like to propose a new operator for optional assignment in Swift.<br class=""><br class="">The idea is that by using this operator (e.g. by doing a ?= b), the optional on the right would be assigned to the variable on the left only when it has something to assign (i.e. when it's not nil).<br class=""><br class="">The implementation could be something as follows:<br class=""><br class="">/// Optional Assignment Operator<br class="">infix operator ?=: AssignmentPrecedence<br class=""><br class="">func ?=<T>(left: inout T, right: T?) {<br class=""> if right != nil {<br class=""> left = right!<br class=""> }<br class="">}<br class=""><br class="">func ?=<T>(left: inout T?, right: T?) {<br class=""> if right != nil {<br class=""> left = right<br class=""> }<br class="">}<br class=""><br class="">I hope you will consider adding this on a future release of this great programming language.<br class=""><br class="">Kind regards,<br class="">N. S.<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></div></body></html>