3 ms·
> you can't forget a "break", and you can't forget to assign into `x`. Same benefits that you also get with: string x = y == 0 ? "foo" : y == 1 ? "b
by jolmg 6y ago
> you can't forget a "break", and you can't forget to assign into `x`.
Same benefits that you also get with:
string x
= y == 0 ? "foo"
: y == 1 ? "bar"
: "baz"
;
Only, using ?: additionally forces you via syntax to specify what x's value should be when all prior conditions fail. In both your examples, x is undefined when y is neither 0 nor 1.
- im3w1l 6y agoAn autoformatter will ruin the way you laid it out and make it look awful.
- userbinator 6y agoThen stop using or pandering to stupid tools.
- saagarjha 6y agoThat's a mean way to refer to your coworkers…
- jolmg 6y agoThe formatting is besides the point.