diff options
Diffstat (limited to 'tests/generics/tgenericlambda.nim')
-rw-r--r-- | tests/generics/tgenericlambda.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/generics/tgenericlambda.nim b/tests/generics/tgenericlambda.nim new file mode 100644 index 000000000..f7aafe1d9 --- /dev/null +++ b/tests/generics/tgenericlambda.nim @@ -0,0 +1,18 @@ +discard """ + output: "10\n10\n1\n2\n3" +""" + +proc test(x: proc (a, b: int): int) = + echo x(5, 5) + +test(proc (a, b): auto = a + b) + +test do (a, b) -> auto: a + b + +proc foreach[T](s: seq[T], body: proc(x: T)) = + for e in s: + body(e) + +foreach(@[1,2,3]) do (x): + echo x + |