Perfect relationship

(Shamelessly stolen from reddit)

231 points · 14 comments · view on lemmy.world

14 Comments

WiredBrain@lemmy.ca · 19 pts · 1y (12 replies)

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

edinbruh@feddit.it · 42 pts · 1y

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

MightBeFluffy@pawb.social · 25 pts · 1y (2 replies)
[ removed ]
tja@sh.itjust.works · 7 pts · 1y (1 reply)

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

48954246@lemmy.world · 3 pts · 1y

I like the python way as it reads more naturally

a = 2 if isTrue else 9
mobotsar@sh.itjust.works · -3 pts · 1y (5 replies)

The joke is that the people in the conversation are kinda dumb

lena@gregtech.eu · 1 pts · 1y (4 replies)

What?

mobotsar@sh.itjust.works · -1 pts · 1y (3 replies)

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.

lena@gregtech.eu · 2 pts · 1y

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.

andronicus@lemmy.world · 2 pts · 1y (1 reply)

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

mobotsar@sh.itjust.works · 1 pts · 1y

Yeah.. well, you know.

pocker_machine@lemmy.world · -3 pts · 1y (1 reply)

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

lena@gregtech.eu · 3 pts · 1y

Very useful reply 👍

catty@lemmy.world · 10 pts · 1y (1 reply)

Clearly virgins

flambonkscious@sh.itjust.works · 5 pts · 1y

To my deranged Friday afternoon brain, this is the funniest bit