[swift-evolution] ternary operator ?: suggestion

Chris Lattner clattner at apple.com
Sat Dec 5 11:09:36 CST 2015


> On Dec 4, 2015, at 11:43 AM, J. Cheyo Jimenez <cheyo at masters3d.com> wrote:
> 
> I'd like some feedback from the core team to see if eliminating the ternary operator and replacing it with if-else is even proposal worthy. 
> 
> Some interesting code in the standard library that uses the ternary operator quite a bit. 
> 
> https://gist.github.com/masters3d/7b0c6f3653368afe4357 <https://gist.github.com/masters3d/7b0c6f3653368afe4357>

FWIW, I have no love for the ternary operator (it is totally "bizarre C magic”), but it does solve a problem that Swift currently otherwise has no solution for.

If you’re interested in pursuing this, then the right path forward is to build a holistic proposal to turn statements (like if and switch) into expressions.  This is subtle and requires thought, but is widely desired and if someone were interested in driving the design and implementation, then I’d be interested to see it happen.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/9fbdba0f/attachment.html>


More information about the swift-evolution mailing list