this post was submitted on 17 Jul 2025
232 points (86.9% liked)

Programmer Humor

25328 readers
1162 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

(Shamelessly stolen from reddit)

you are viewing a single comment's thread
view the rest of the comments
[–] edinbruh@feddit.it 42 points 1 week ago

"Ternary operator" means "operator that takes three things", like unary and binary operators take one and two things.

In C there is an operator for conditional expressions (an 'if' that you can put inside expressions) and it looks like this condition ? trueBranch : falseBranch. It takes three expressions, so it's a ternary operator.

Except it's the only ternary operator in C (and most languages, if they have one at all), so instead of calling it something like "conditional operator", they just call it "the ternary operator"