3 ms·
I don't see how either of those is simpler than string x = y ? "foo" : "bar"; or if y can take more values than 0 or 1, then that strongly suggests it sho
by userbinator 6y ago
I don't see how either of those is simpler than
string x = y ? "foo" : "bar";
or if y can take more values than 0 or 1, then that strongly suggests it should become a table lookup:
string x = some_strings[y];
- usefulcat 6y agoI think the point is more the general technique, not this particular usage of it. Regarding the ternary, nested ternary expressions aren't the most readable thing. Regarding table lookup, sure but only if all values of y are sequential integers.