conditional expressions
/// Conditional Expression
void main()
{
/// Type 1
/// Condition ? expression1 : expression2
// var a = 10, b = 20;
// (a>5) ? print("True") : print("False");
// (b<15) ? print("True") : print("False");
/// Type 2
/// expression1 ?? expression2
//in the above syntax if expression1 is not null, then it gets evaluated else expression2 is evaluated
// var c = 10, d = 22, e = null, f = 40;
// var temp = c ?? d;
// var temp1 = e ?? f;
// print(temp);
// print(temp1);
//Another Example
var ans;
ans ?? print("Ans is null!");
}
Comments
Post a Comment