Nim/tests/compile/ttypeclasses.nim
2013-05-27 23:16:00 +02:00

34 lines
450 B
Nim

type
TFoo[T] = object
val: T
T1 = expr
T2 = expr
proc takesExpr(x, y) =
echo x, y
proc same(x, y: T1) =
echo x, y
proc takesFoo(x, y: TFoo) =
echo x.val, y.val
proc takes2Types(x,y: T1, z: T2) =
echo x, y, z
takesExpr(1, 2)
takesExpr(1, "xxx")
takesExpr[bool, int](true, 0)
same(1, 2)
same("test", "test")
var f: TFoo[int]
f.val = 10
takesFoo(f, f)
takes2Types(1, 1, "string")
takes2Types[string, int]("test", "test", 1)