조용한 담장

Dart : Operators 본문

Dart

Dart : Operators

iosroid 2019. 9. 17. 17:01

참조: Dart language tour

 

Prefix and postfix increment and decrement operator

++ --

 

a++; ++a; a--; --a;

Arithmetic operator

+ - * / ~/ &

 

a + b; a - b; a * b; a / b; a ~/ b; a % b;

Assignment operator

= ??=        
-= += *= /= ~/= %=
<<= >>= &= ^= |=  
a = b; a ??= b;
a -= b; a += b; a *= b; a /= b; a ~/= b; a %= b;
a <<= b; a >>= b; a &= b; a ^= b; a |= b;

Bitwise, shift operator

& ~ | ^ << >>
(a & b); (a & ~b); (a | b); (a ^ b); (a << 4); (a >> 4);

Equality and relational operator

== !=    
> < >= <=
a == b; a != b; a > b; a < b; a >= b; a <= b;

Conditional expression

condition ?  expr1 : expr2 expr1 ?? expr2

 

c ? a : b; (a ?? b);

Type test and type cast operator

as is is!

 

if (a is T) a.b = 1; if (a is! T) = a.b = 1; (a as T).b = 1;

Logical operator

! || &&

 

!a; a || b; a && b;

Member access operator

. ?.
T a; a.b; a?.b;

Cascade notation

..
var a = classA();
a.b = 1
a.add(2);

classA()
  ..b = 1
  ..add(1)

 

'Dart' 카테고리의 다른 글

Dart : Exceptions  (0) 2019.09.20
Dart : Control flow statements  (0) 2019.09.17
Dart 2.5  (0) 2019.09.11
Dart : Functions  (1) 2019.08.07
Dart : Variables  (0) 2019.08.05
Comments