Comment

Comment by mjcohen

A comment about ternarys:

Nested ternarys can be quite readable if they are formatted like nested if-then-elses.

Here's an example from some awk code I wrote about 15 years ago.

       vval = ((k > 1 \
         ? substr(vval, 1, k-1) \
         : "" \
         ) \
        substr(vv, length(vpfx)+1, 1) \
        vvn \
        (k1 <= length(vval) \
         ? substr(vval, k1) \
         : "" \
         ) \
        );
Well, at least I find it readable.
parent mjcohen 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton