Hello, what is mean (a?b :c) ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hello, what is mean (a?b :c) ?

20th Jan 2019, 7:31 AM
lap
lap - avatar
4 Answers
+ 4
Ternary is mentioned in the first slide of this lesson. https://www.sololearn.com/learn/Swift/2337/?ref=app ... and the second slide of part 2: https://www.sololearn.com/learn/Swift/2338/?ref=app
20th Jan 2019, 7:41 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
It means: Is a true? In that case b: else c. Does that clarify it?
20th Jan 2019, 7:36 AM
HonFu
HonFu - avatar
+ 2
that is the ternary operator. condition ? expression_for_true : expression_for_false. if the condition is true (or it is truthy) the first expression is returned, in the general form written above that would be expression_for_true. otherwise, if the condition evaluates to false (or is falsy) it returns the second expression, from the above example it returns expression_for_false. Besides false, possible falsy expressions are: null, NaN, 0, the empty string (""), and undefined.
20th Jan 2019, 7:41 AM
notqueued
notqueued - avatar
+ 1
it means is "a" true? if NOT? check "b" : is "b" true? else?? check "c"
21st Jan 2019, 1:21 PM
fatemeh