summary refs log tree commit diff stats
path: root/tests/generics/tgenericlambda.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <ar@kimeta.de>2014-04-10 01:47:20 +0200
committerAndreas Rumpf <ar@kimeta.de>2014-04-10 01:47:20 +0200
commitdcfc7a8896166563f6fd80fbab81bc50e0b5a217 (patch)
tree4a247ec2d64bafec53e5ab24b0fda89642908a07 /tests/generics/tgenericlambda.nim
parenta86c774932afd8b6782df1925837df9df04ef381 (diff)
parent8b82004359b8d852fa0107d79cc78b21eb35c028 (diff)
downloadNim-dcfc7a8896166563f6fd80fbab81bc50e0b5a217.tar.gz
resolved conflict
Diffstat (limited to 'tests/generics/tgenericlambda.nim')
-rw-r--r--tests/generics/tgenericlambda.nim23
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()