activa


Comments:

Write more empty lines! They will be read!

posted by activaactiva(2340) 4 years, 2 months ago 0

You're lucky I don't have to do your code reviews :D

Reply

if ... else if ... else if ... else ... : an alternative

posted by activaactiva(2340) 4 years, 2 months ago 0

You people are hilarious.

What a fuss over a stupid article about a simple language feature that few people know about. The code sample I gave is not complicated, and cleaner than the if-then-else way of writing it, *IN THIS SPECIFIC CASE*. And in this case, even if someone doesn't have a clue about what the ternary operator does, he/she will still capture the meaning of that piece of code, because of the way it is written.

I would never recommend this pattern for performing complex conditional assignments. It's just a piece of code showing the "special" behavior of a right-associative operator such as the ternary operator.

Reply