Such an operator was proposed here: https://github.com/apple/swift-evolution/blob/60a8980a66a0a1341871ec323797c5547d0e0925/proposals/0024-optional-value-setter.md
It was ultimately rejected: https://lists.swift.org/pipermail/swift-evolution-announce/2016-February/000043.html Stephen > On Dec 21, 2017, at 11:44 AM, Benoit Pereira da silva via swift-evolution > <swift-evolution@swift.org> wrote: > > Dear all, > > That’s not ambitious but i think worth be explored. > > What do you think for example of this Infix operator? > « =? » allows to express optional assignments in a very concise way. > > > // The `=? operator allows simplify optional assignements : > // `a = b ?? a` can be written : `a =? b` > infix operator =?: AssignmentPrecedence > > public func =?<T> ( left:inout T?, right: T? ){ > left = right ?? left > } > > public func =?<T> ( left:inout T, right: T? ){ > left = right ?? left > } > > > Do you have such operators that you really use very often? > > > > Best regards > > Benoit > > > > Benoit Pereira da Silva > Ultra Mobile Developer & Movement Activist > Développeur Ultra Mobile & Militant du mouvement > https://pereira-da-silva.com <https://pereira-da-silva.com/> > > <bannerp.jpg> > > > > ✄ -------------------------------- > This e-mail is confidential. Distribution, copy, publication or use of this > information for any purpose is prohibited without agreement of the sender. > 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. > > > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution