re: We don't need a ternary operator VIEW POST

FULL DISCUSSION
 

It could be that calling it an operator is simply confusing.

Coffeescript has a

if (b < 5) then b else 5

Which makes it look more like an inline if that returns its values from the if or else block.

So, the conditional operator would be more like:

let a = (function() { 
    if (b < 5)
        return b;
    else
        return 5;
})();

I really like the solution though, it makes so much more sense to have it be made up of binary operators now. It doesn't even make sense to add the conditional operator back in since the ? and | are already fully encompassing its use cases.

 

I really dislike the inline if ... else forms that some languages have, also including Python. It looks really messy, and more like a flow statement than an expression.

code of conduct - report abuse