Conditional Expressions
cond ? a : b and a ?? b choose between values.
Example
var n = 7;
print(n.isEven ? "even" : "odd");
String? s;
print(s ?? "default");
print((s?.isEmpty ?? true) ? "empty" : "has text");Exercise
Ternary.
c a : b
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.