1 Star 0 Fork 28

felixw/dart_in_action

forked from ryanpenn/dart_in_action
暂停
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
10_ closures.dart 550 Bytes
一键复制 编辑 原始数据 按行查看 历史
ryanpenn 提交于 2019-03-27 10:55 . dart programming
///
/// Closures
///
main(List<String> args) {
// A closure is a function that has access to the parent scope
String message = "Dart is good";
Function showMessage = () {
message = "Dart is awesome";
print(message);
};
showMessage();
print(message);
// A closure is a function object that has access to variables in its lexical scope
Function talk = () {
String msg = "Hi";
Function say = () {
msg = "Hello";
print(msg);
};
return say;
};
Function speak = talk();
speak();
talk()();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Dart
1
https://gitee.com/felixw/dart_in_action.git
git@gitee.com:felixw/dart_in_action.git
felixw
dart_in_action
dart_in_action
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385