Dart编程实例 - typedef 类型定义
本文为大家分享 Dart编程实例 - typedef 类型定义 的具体示例代码,提供大家参考,具体内容如下:
typedef ManyOperation(int firstNo , int secondNo); //function signature Add(int firstNo,int second){ print("Add result is ${firstNo+second}"); } Subtract(int firstNo,int second){ print("Subtract result is ${firstNo-second}"); } Divide(int firstNo,int second){ print("Divide result is ${firstNo/second}"); } Calculator(int a, int b, ManyOperation oper){ print("Inside calculator"); oper(a,b); } void main(){ ManyOperation oper = Add; oper(10,20); oper = Subtract; oper(30,20); oper = Divide; oper(50,5); }
本文为大家分享 Dart编程实例 - 导入和使用库 的具体示例代码,提供大家参考,具体内容如下:import 'dart:math';void main() { print("Square root of ...