dart注意点记录

2019-10-14  本文已影响0人  liboxiang
Function makeAdder(num addBy) {
  return (num i) => addBy + i;
}

void main() {
  // Create a function that adds 2.
  var add2 = makeAdder(2);

  // Create a function that adds 4.
  var add4 = makeAdder(4);

  assert(add2(3) == 5);
  assert(add4(3) == 7);
}
assert(5 / 2 == 2.5); // Result is a double
assert(5 ~/ 2 == 2); // Result is an int
b ??= value;
var command = 'OPEN';
switch (command) {
  case 'OPEN':
    continue nowClosed;
  
  case 'CLOSED':
    print('closed');
    break;
  nowClosed:
  default:
    print('default');
}
class A{

}
class B extends A{

}

A a = A();
  B b = B();
  if(b.runtimeType == A) {
    print('b.runtimeType is A');
  }
  else {
    print('b.runtimeType is not A');
  }
  if(b is A) {
    print('b is A');
  }
  else {
    print('b is not A');
  }
上一篇 下一篇

猜你喜欢

热点阅读