3 ms·
i agree about the "first smell", the inverted condition, and fairly recently started doing the reverse: $x=a if (condition) then $x=b
by croisillon 2y ago
i agree about the "first smell", the inverted condition, and fairly recently started doing the reverse:
$x=a
if (condition) then $x=b
- emorning3 2y agoI like this, I think it's easier to read. I don't care that its not the most efficient way to do things, programming languages exist to make things easier for me.
- emorning3 2y ago$x=a if (condition) then $x=b If you think of programs as logic then I see the lines above as a logical expression written in CNF conjunctive normal form, where each line is a clause. whereas this... $x = condition ? b : a; ...is like a nested logical expression. And breaking the program down into clauses makes it easier to understand, for humans and computers.