4 ms·
I find inline Java ternaries often make the code easier to read overall than a whole if-else block, for two reasons: 1. The code is shorter, so there's less to
by ShardPhoenix 16y ago
I find inline Java ternaries often make the code easier to read overall than a whole if-else block, for two reasons:
1. The code is shorter, so there's less to read in the first place.
2. The value returned is being used right where it's needed, so you don't have to carry it so far in your head.
I certainly don't use them all the time though, just for short/simple expressions.