Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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];


I 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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: