The ternary operator is a way to concisely say:
“If test, then a, else b“,
with the value of the statement being the value of a or b.
a if test else b
Ok. Now that I’ve written this post, I’ll remember it.
However, I just want to say…
On behalf of all of the other multiple-language programmers in the world, …
THIS IS LAME!!!
Well, there are some reasonable reasons.
As noted in the comments, the Python version is more readable (at least in English).
And, to tell you the truth, if I ONLY were programming in Python, I’d probably prefer the Python version.
I understand the reasoning behind Python’s version.
I JUST DON’T AGREE WITH IT!
<h2> Rant over </h2> <p> Glad I’ve gotten that off my chest. </p>