-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_Operators.dart
70 lines (55 loc) · 992 Bytes
/
6_Operators.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
main(List<String> args) {
int num = 10 + 22;
num = num - 2;
print(num);
num = num % 5;
print(num);
if (num == 0) {
print("Zero");
}
num = 100;
num *= 2;
print(num);
// Unary operator
++num;
num++;
num--;
--num;
num += 1;
num -= 1;
print(num);
// Logical && and || operators used for logical check .
if(num > 200 && num < 203) {
print("200 to 203");
}
// != Not equal
if(num != 100) {
print("num is not equal to 100");
}
int x = 100;
var result = x % 2 == 0 ? "Even" : "Odd";
print(result);
// Null Aware Operator.
// (?.), (??), (??=)
var n = Num();
int number;
if (number != null) {
n.num = number;
}
print(n.num);
var n1 = Num();
int anumber;
anumber = n1?.num ?? 1;
print("An optional anumber $anumber");
int bnumber;
// If null assign 100
print(bnumber ??= 100);
print(bnumber);
var x1 = 10;
if ( x1 is int) {
print('integer');
}
}
class Num {
int num = 10;
}