<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Such an operator was proposed here: <a href="https://github.com/apple/swift-evolution/blob/60a8980a66a0a1341871ec323797c5547d0e0925/proposals/0024-optional-value-setter.md" class="">https://github.com/apple/swift-evolution/blob/60a8980a66a0a1341871ec323797c5547d0e0925/proposals/0024-optional-value-setter.md</a><div class=""><br class=""></div><div class="">It was ultimately rejected: <a href="https://lists.swift.org/pipermail/swift-evolution-announce/2016-February/000043.html" class="">https://lists.swift.org/pipermail/swift-evolution-announce/2016-February/000043.html</a></div><div class=""><br class=""></div><div class="">Stephen<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 21, 2017, at 11:44 AM, Benoit Pereira da silva 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=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Dear all,</div><div class=""><br class=""></div><div class="">That’s not ambitious but i think worth be explored.</div><div class=""><br class=""></div><div class="">What do you think for example of this Infix operator?</div><div class="">« =? » allows to express optional assignments in a very concise way.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(125, 126, 126); background-color: rgb(0, 58, 93);" class="">// The `=? operator allows simplify optional assignements :</div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(125, 126, 126); background-color: rgb(0, 58, 93);" class="">// `a = b ?? a` can be written : `a =? b`</div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(189, 178, 160); background-color: rgb(0, 58, 93);" class=""><span style="color: #c66576" class="">infix</span> <span style="color: #c66576" class="">operator</span> =?: AssignmentPrecedence</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(0, 58, 93); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(189, 178, 160); background-color: rgb(0, 58, 93);" class=""><span style="color: #c66576" class="">public</span> <span style="color: #c66576" class="">func</span> =?<T> ( left:<span style="color: #c66576" class="">inout</span> <span style="color: #3fa7ad" class="">T</span>?, right: <span style="color: #3fa7ad" class="">T</span>? ){</div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(189, 178, 160); background-color: rgb(0, 58, 93);" class=""> left = right ?? left</div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(189, 178, 160); background-color: rgb(0, 58, 93);" class="">}</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(0, 58, 93); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(189, 178, 160); background-color: rgb(0, 58, 93);" class=""><span style="color: #c66576" class="">public</span> <span style="color: #c66576" class="">func</span> =?<T> ( left:<span style="color: #c66576" class="">inout</span> <span style="color: #3fa7ad" class="">T</span>, right: <span style="color: #3fa7ad" class="">T</span>? ){</div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(189, 178, 160); background-color: rgb(0, 58, 93);" class=""> left = right ?? left</div><div style="margin: 0px; font-stretch: normal; font-size: 13.5px; line-height: normal; font-family: Menlo; color: rgb(189, 178, 160); background-color: rgb(0, 58, 93);" class="">}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Do you have such operators that you really use very often?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Best regards </div><div class=""><br class=""></div><div class="">Benoit</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><div class="">
<div style="font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 14px;" class=""><div apple-content-edited="true" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span style="font-size: 12px; line-height: normal; orphans: 2; widows: 2;" class=""><font face="HelveticaNeue-Light" class=""><div style="orphans: auto; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><b class="">Benoit Pereira da Silva</b></div><div style="margin: 0px; line-height: normal;" class="">Ultra Mobile Developer & Movement Activist</div><div style="margin: 0px; line-height: normal;" class="">Développeur Ultra Mobile & Militant du mouvement</div><div style="margin: 0px; line-height: normal;" class=""><a href="https://pereira-da-silva.com/" class="">https://pereira-da-silva.com</a></div><div style="margin: 0px; line-height: normal;" class=""><span style="line-height: normal;" class=""></span></div></div></div><div style="orphans: auto; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class=""></span></div></font></span></div></div></div></div></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: 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;" class=""><br class="Apple-interchange-newline" 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; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal;"><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; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal;" class=""><span class=""><span class=""><span class=""><span class=""><span class=""><span class=""><span class=""><span class=""><span id="cid:E3AF4CA8-D774-47D1-AF27-2B086409AEED@home"><bannerp.jpg></span></span><div 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; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: 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;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: 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;" class=""><span class=""><span class=""><br class="Apple-interchange-newline"><br class="Apple-interchange-newline"><br class=""></span></span></span></span></div><div 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; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: 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;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: 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;" class=""><span class=""><span class=""><div style="font-family: HelveticaNeue-Light; orphans: 2; widows: 2;" class=""><div class=""><span style="orphans: auto; widows: auto; background-color: rgb(255, 255, 255);" class="">✄ --------------------------------</span><br style="orphans: auto; widows: auto;" class=""><font size="1" style="orphans: auto; widows: auto;" class="">This e-mail is confidential. Distribution, copy, publication or use of this information for any purpose is prohibited without agreement of the sender.<br class="">Ce message est confidentiel. Toute distribution, copie, publication ou usage des informations contenues dans ce message sont interdits sans agrément préalable de l'expéditeur.</font><br style="orphans: auto; widows: auto;" class=""></div></div></span></span></span></span></div><br class="Apple-interchange-newline" 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; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal;"><br class="Apple-interchange-newline" 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; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal;">
</span></span></span></span></span></span></span></span></span></div>
<br class=""></div></div>_______________________________________________<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></blockquote></div><br class=""></div></body></html>