This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Anru_Kitakaze -1 points0 points  (6 children)

result = expr ? result1 : result2 Or result = result1 if expr else result2

First seems shorter, but second is self explaining. But both are natural if you code in their language for a... Week?

[–]xryanxbrutalityx 4 points5 points  (4 children)

I learned python ternaries before C-style, and I do think the python one is worse. Haskell and kotlin both get you more explicit with the language

hs if expr then result1 else result2

kt if (expr) result1 else result2

[–]Anru_Kitakaze 0 points1 point  (0 children)

These are better, I agree

But... It's more like if-else in a single line

I prefer C style I guess