可调用类

PPG007 ... 2022-3-14 Less than 1 minute

# 可调用类

通过实现类的 call() 方法,允许使用类似函数调用的方式来使用该类的实例。

class sum {
  int call(int a, int b) => a + b;
}

void main(List<String> args) {
  var s = sum();
  print(s(4, 6));
}
1
2
3
4
5
6
7
8
Last update: March 14, 2022 11:52
Contributors: PPG007