4 ms·
Because you can deduplicate certain parts of the logic which make the whole thing less error prone, such as if c x=1 else x=2 If I ever wa
by bruce343434 3mo ago
Because you can deduplicate certain parts of the logic which make the whole thing less error prone, such as
if c
x=1
else
x=2
If I ever want to change x, or refactor this code some other way, its a more brittle process over x=c?1:2
The ternary expression also takes up much less space so there is less of an emphasis on it, this can be a stylistic tool in a programmer's toolbox
- lucas_t_a 3mo agothe oposite is also true, you can have misleading side effects coming from joining things into a single expression