Dart细节之运算符

发布于 16 天前  0 次阅读


除(取整):~/

void main() {
  print(1 ~/ 3); //0
  print(2 ~/ 3); //0
}

类型转换:as

void main() {
  int a = 1;
  num b = a as num;
  print(b); //1
  print(b.runtimeType); //int
}

类型操作:is,is!

//yes
void main() {
  int a = 1;
  if (a is int) {
    print('yes');
  } else {
    print('no');
  }
}


平平无奇的大学在读本科生