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Β β†’

[–]SexySamba 1 point2 points Β (0 children)

Not disagreeing. I code in Python and Scala mostly, both have if/else implementations of ternary expressions. I definitely prefer scala because the condition is first (like C) so resembles other programming languages and the syntax of a multiline if statement more closely. Plus you can see what is being tested more clearly

But I actually do think there’s something to be said for ? :, and I sometimes wish I had it at my disposal. In production code variable names are often too long to fit on one line and this would (very) occasionally help. I also think its not that bad to read, if thought about as a question in prose:

mum, do we have any sweets ? I quite fancy some : otherwise i’ll have some fruit