2 ms·
> This is ugly and hard to read compared to trailing if. For short statements like the examples given here, it's not ugly and it's easy to read. Whether it's e
by esperent 4y ago
> This is ugly and hard to read compared to trailing if.
For short statements like the examples given here, it's not ugly and it's easy to read. Whether it's easier/harder to read than trailing if depends on how familiar you are with each syntax. I don't think either is superior in this example.
I agree ternaries are not suitable for long complex statements.
However, I don't think trailing if is suitable for long complex statements either. I've generally only seen it used in simple cases.