Ternary Operator Fan Club
Description
The image is a SpongeBob crowd-reaction meme with SpongeBob yelling excitedly while other characters look startled or uncomfortable. The top text reads `I FUCKING LOVE THE TERNARY OPERATOR`, and the bottom text reads `I LOVE MAKING IF STATEMENTS IN ONE LINE`, with an `imgflip.com` watermark in the lower-left corner. The developer joke is about the ternary operator turning simple conditional logic into compact one-liners that some programmers love and others find unreadable. It reflects a real code review tension: brevity can be expressive, but nested or overused ternaries quickly become syntax golf disguised as clarity.
Comments
22Comment deleted
A ternary is elegant until the third `?` turns your business rule into a CAPTCHA for maintainers.
let x = ((y * 2)**(1/2))<4 ? 2+y/2 : 2-y/2 no comment needed, code is self-explanatory Comment deleted
I like how in kotlin everything returns value, so you can do this with if-else Comment deleted
let x = ((y * 2) ** (1/2)) < 4 ? 2 + y / 2 : 2 - y / 2 would be more readable and still better than explicit if-else, IMHO, especially when clauses grow in size and complexity. Comment deleted
true Comment deleted
2 + y / sqrt(y * 2) < 4 ? 2 : -2; Comment deleted
let x = if (y * 2).sqrt() < 4 { 2 + y/2 } else { 2 - y/2 } Looks not so bad, really (Rust lang) Comment deleted
+1 Comment deleted
what is y ? Comment deleted
LITERALLY ME Comment deleted
IF THE CODE IS COMPACT, IT IS GOOD Comment deleted
Python's one is kinda sad though :( It used to feel cool, but now it's just so bloated Comment deleted
Same with list comprehensions.. Map/filter/reduce really puts python list comprehensions to shame Comment deleted
Yeaaaah! Makes even less sense now! Comment deleted
I need to finally learn Rust, it sounds really interesting Comment deleted
This is nothing, try functional point-free style. Comment deleted
Sadly there is no such thing in rust... We can just use one liner if and else... The worse thing is we still need to use brackets 😐 if bool { one } else { two } Comment deleted
Sadly there's rust Comment deleted
Although I think we going to get it without the brackets in later versions... (Already in nightly) Comment deleted
golang var x int if ((y*2)**(1/2))<4 { x = 2+y/2 } else { x = 2-y/2 } 😑😂😂😂 Comment deleted
I hate Kotlin for not supporting this from Java 😢 Comment deleted
return option1 or option2 Comment deleted