ternary operator ?: suggestion


(Rainer Brockerhoff) #1

I've reread my existing code. Ternary is very convenient but I'd vote
for either leaving it alone completely or find a Swift-y alternative
that enforces ( )s around the options.

That said, I couldn't really find any place where a "ternary-like switch
expression" would help much.

···

On 4/1/16 20:59 , swift-evolution-request@swift.org wrote:

Date: Mon, 4 Jan 2016 17:03:54 -0600
From: Matthew Johnson <matthew@anandabits.com>
To: Paul Ossenbruggen <possen@gmail.com>
Message-ID: <FE211ADC-F2A9-4485-B869-93BC8378ECD9@anandabits.com>

> On Jan 4, 2016, at 2:37 PM, Paul Ossenbruggen via swift-evolution <swift-evolution@swift.org> wrote:
>
> Good feedback, I am all for making it feel more like swift. Any ideas would be welcome. I will also try to come up with some myself.

My suggestion is to leave ternary alone and try to come up with a ternary-like switch expression that is workable. I think that is likely the best change possible at this point.

--
Rainer Brockerhoff <rainer@brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://brockerhoff.net/blog/