diff options
author | Andreas Rumpf <ar@kimeta.de> | 2014-04-10 01:47:20 +0200 |
---|---|---|
committer | Andreas Rumpf <ar@kimeta.de> | 2014-04-10 01:47:20 +0200 |
commit | dcfc7a8896166563f6fd80fbab81bc50e0b5a217 (patch) | |
tree | 4a247ec2d64bafec53e5ab24b0fda89642908a07 /tests/generics/tgenericlambda.nim | |
parent | a86c774932afd8b6782df1925837df9df04ef381 (diff) | |
parent | 8b82004359b8d852fa0107d79cc78b21eb35c028 (diff) | |
download | Nim-dcfc7a8896166563f6fd80fbab81bc50e0b5a217.tar.gz |
resolved conflict
Diffstat (limited to 'tests/generics/tgenericlambda.nim')
-rw-r--r-- | tests/generics/tgenericlambda.nim | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/generics/tgenericlambda.nim b/tests/generics/tgenericlambda.nim new file mode 100644 index 000000000..eb6ada3e5 --- /dev/null +++ b/tests/generics/tgenericlambda.nim @@ -0,0 +1,23 @@ +discard """ + output: "10\n10\n1\n2\n3\n15" +""" + +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 + +proc foo = + let x = proc (a, b: int): auto = a + b + echo x(5, 10) + +foo() |