[swift-evolution] Should we incorporate bunches of new operators / micro-syntactic sugar?

Benoit Pereira da silva bpds at me.com
Wed Dec 20 12:27:32 CST 2017


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/>





✄ --------------------------------
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.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171220/53b839c2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bannerp.jpg
Type: image/jpeg
Size: 27829 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171220/53b839c2/attachment.jpg>


More information about the swift-evolution mailing list