Spyke
lemmy.ca

I'm not CS smart enough to understand this... 😢

19

"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"

42
TJA!reply
sh.itjust.works

I really like the way kotlin is doing it. The readability of the first one and still a direct assignment.

var a = if (isTrue) 2 else 9

7

I like the python way as it reads more naturally

a = 2 if isTrue else 9
3
lemmy.world

Honestly, it is not worth it and only mildly funny. You didn’t miss anything.

-3
mobotsarreply
sh.itjust.works

Well if you make me actually explain it, I'm going to sound like an asshole; the joke is so obvious and low-level and the type of humor so uninspired that I figure they must be a little.. you know, dumb.

-1

It's not the best joke I've seen, but I wouldn't call it dumb. To each their own, I guess. Jokes are subjective.

2
andronicusreply
lemmy.world

Well if you make me actually explain it, I'm going to sound like an asshole

Too late muchacho... you're already giving real big superiority vibes here

2

You reached the end