From 560a3bad2882e149714e551f82edeb506cc2b241 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 10 Feb 2012 14:50:06 +0200 Subject: `do' keyword in the grammar for lambda blocks --- tests/run/tclosure.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') 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 -- cgit 1.4.1-2-gfad0