(no title)
bogomog | 11 months ago
function getOddness(n: number):
return (n % 2 === 0)
? "Even"
: "Odd";
Lowest boilerplate makes it the most readable. If working in a language with the ternary operator it ought to be easily recognized!
ajuc|11 months ago
pasc1878|11 months ago
stared|11 months ago
erikerikson|11 months ago
lioeters|11 months ago
unknown|11 months ago
[deleted]
culopatin|11 months ago
bogomog|11 months ago
erikerikson|11 months ago
Choosing one of world's spoken languages over others seems to be the opposite of inclusive.
elliottkember|11 months ago
Twisol|11 months ago
To me and my style of coding, there's a difference of intent between the two. A ternary connotes a mere computation, something that should have no side-effects. A conditional connotes a procedure; the arms of the conditional might be expected to have side-effects. (And the case of `if (_) return` or similar are pure control flow guards; they neither compute a value nor perform a procedure as such.)
It's not just about where the symbols go on the screen.