Perfect relationship
-
(Shamelessly stolen from reddit)
I'm not CS smart enough to understand this...
-
I'm not CS smart enough to understand this...
wrote on last edited by [email protected]A ternary is a short hand to assign a value based on a true/false statement
let a; if(isTtrue) a=2 else a=9
Becomes
let a = (isTrue) ? 2 : 9
-
(Shamelessly stolen from reddit)
Clearly virgins
-
I'm not CS smart enough to understand this...
"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"
-
I'm not CS smart enough to understand this...
Honestly, it is not worth it and only mildly funny. You didn’t miss anything.
-
Clearly virgins
To my deranged Friday afternoon brain, this is the funniest bit
-
A ternary is a short hand to assign a value based on a true/false statement
let a; if(isTtrue) a=2 else a=9
Becomes
let a = (isTrue) ? 2 : 9
wrote on last edited by [email protected]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
-
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
wrote on last edited by [email protected]I like the python way as it reads more naturally
a = 2 if isTrue else 9
-
I'm not CS smart enough to understand this...
The joke is that the people in the conversation are kinda dumb
-
Honestly, it is not worth it and only mildly funny. You didn’t miss anything.
Very useful reply