diff options
author | Zahary Karadjov <zahary@gmail.com> | 2012-02-10 14:50:06 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2012-02-10 14:50:35 +0200 |
commit | 560a3bad2882e149714e551f82edeb506cc2b241 (patch) | |
tree | 39144203a4c476cf34b5615142c1199416d53490 /tests/run | |
parent | 74498d616eaae30605d7323254c46f5af4ae253c (diff) | |
download | Nim-560a3bad2882e149714e551f82edeb506cc2b241.tar.gz |
`do' keyword in the grammar for lambda blocks
Diffstat (limited to 'tests/run')
-rwxr-xr-x | tests/run/tclosure.nim | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/run/tclosure.nim b/tests/run/tclosure.nim index d7c0ec0e3..372e296d0 100755 --- a/tests/run/tclosure.nim +++ b/tests/run/tclosure.nim @@ -12,6 +12,10 @@ proc foldr(n: openarray[int], fn: proc (x, y: int): int {.closure}): int = for i in 0..n.len-1: result = fn(result, n[i]) +proc each(n: openarray[int], fn: proc(x: int) {.closure.}) = + for i in 0..n.len-1: + fn(n[i]) + var myData: array[0..4, int] = [0, 1, 2, 3, 4] @@ -24,8 +28,10 @@ proc testA() = inc(p)) testA() -for x in items(myData): + +myData.each do (x: int): write(stout, x) + #OUT 2 4 6 8 10 |