3 ms·
I agree with this. The limited location I find that I really miss ternary operations is initialization. v := if foo() { 7 } else { 11 } But this
by ts4z 5y ago
I agree with this. The limited location I find that I really miss ternary operations is initialization.
v := if foo() {
7
} else {
11
}
But this means {} blocks now have values, which is weird in a C derivative. Of course, one could do
v := func() int {
if foo() {
return 7
} else {
return 11
}
}()
but... that's kind of awful.