utypeclasses.nim 364 B

1234567891011121314
  1. import unittest
  2. proc concat(a, b): string =
  3. result = $a & $b
  4. block: # if proc param types are not supplied, the params are assumed to be generic
  5. check concat(1, "test") == "1test"
  6. check concat(1, 20) == "120"
  7. check concat("foo", "bar") == "foobar"
  8. block: # explicit param types can still be specified
  9. check concat[cstring, cstring]("x", "y") == "xy"