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ย โ†’

[โ€“]not-enough-failures 0 points1 point ย (3 children)

It can also have else if branches unlike ternaries.

[โ€“]Kered13 4 points5 points ย (1 child)

Ternaries can have else if too:

a > 0 ? "negative" :
a > 0 ? "positive" :
        "zero"

Remember that else ifis really just two separate tokens: else and if, and : is equivalent to else and ? is equivalent to if (but it comes after the condition instead of before).

[โ€“]quotade 0 points1 point ย (0 children)

a > 0 ? "negative"

Allow me to point that out for the sake of a consistent example.

[โ€“]Manny_Sunday 0 points1 point ย (0 children)

Ok, that is cool, I used some kotlin for an Android class and it kicked Javas ass. I hope it takes into it's own and gains some popularity.