If-Expressions vs Statements
The cluster debates the use of traditional if-else statements versus conditional expressions like ternary operators, cond, and unless, focusing on syntax, readability, and language features that treat if as an expression.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Surely you are not putting code behind an if/else
why are you so certain? is it maybe because you've programmed your whole life using ifs and they look more natural to you?
Are inline if statements considered good form? I rarely see them in use and I've heard people complain about them before.
Everything is an expression. Including if statements. There is no need of such syntax abominations.
It's an if statement written differently.
Nice! Feature request : conditional expressions should start with the "else" branch.
It simplifies the expression of if/then/elsif/elsif/else, even if it's not total.Why not steal it?
Arenβt features like if-expressions just that?
The reason it's not the same as if...else is that it's freaking backwards :D
There is an 'if' expression, it's just spelled '?' and else is ':'. Mentioned a few posts up.