OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 |
| 7 void main() { |
| 8 Expect.equals('', useParameterInClosure(1)); |
| 9 Expect.equals(43, updateParameterInClosure(1)()); |
| 10 } |
| 11 |
| 12 String useParameterInClosure(arg1, {int arg2}) { |
| 13 if (arg1 is Map) { |
| 14 return arg1.keys.map((key) => arg1[key]).first; |
| 15 } else { |
| 16 return ''; |
| 17 } |
| 18 } |
| 19 |
| 20 Function updateParameterInClosure(arg1) { |
| 21 if (arg1 is Map) { |
| 22 return () => arg1 = 42; |
| 23 } else { |
| 24 return () => arg1 = arg1 + 42; |
| 25 } |
| 26 } |
OLD | NEW |