3 ms·
How about f(a ? b : c, d, e)? The go alternatives are too horrible to even contemplate, but here goes: if a { f(b, d, e) } else { f(c, d, e) }
by boring_twenties 5y ago
How about f(a ? b : c, d, e)?
The go alternatives are too horrible to even contemplate, but here goes:
if a {
f(b, d, e)
} else {
f(c, d, e)
}
or
var tmp WhatFuckingTypeIsThisAgain
if a {
tmp = b
} else {
tmp = c
}
f(tmp, d, e)
It's hard to say which one is worse, but there is no doubt that the C version is "unquestionably easier to read."
- maccard 5y agomy gut reaction was "no, that's exactly why they don't want these sorts of constructs" but the alternative (only allowing it in init statements) is worse I think. Only allowing in init statements is how you end up with the c++ initialization mess. Re; your example, what about tmp := a ? b : c f(tmp, d, e) Even in C++ that's likely how I'd write it.
- boring_twenties 5y agoWorks for me.