cond1 ? res1 :
cond2 ? res2 :
cond3 ? res3 :
or_else_res
If they are truly nested, then that is confusing. But if you have an if-else chain, then it can be quite readable. cond1 ? res1 :
cond2 ? res2 :
cond3 ? res3 :
or_else_res
If they are truly nested, then that is confusing. But if you have an if-else chain, then it can be quite readable.
Or they could just ask granddaddy for advice:
=)An elegant weapon, for a more civilized age...
or
or what is most lua-like?I find that so much harder to read compared to if/else or case/when in ruby.
The ? is basically an attempt to use fewer if/else, at the cost of condensed if-else like structure. I always need to look at both parts after the ? whereas in a single if or elsif I don't. case/when in ruby is even better here e. g. regex check:
(I ommitted the "end"s here to just focus on the conditional logic.)