diff options
-rw-r--r-- | doc/tut2.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/tut2.rst b/doc/tut2.rst index 94725a5d8..32faf452c 100644 --- a/doc/tut2.rst +++ b/doc/tut2.rst @@ -534,6 +534,19 @@ iterator or type. As the example shows, generics work with overloading: the best match of ``add`` is used. The built-in ``add`` procedure for sequences is not hidden and is used in the ``preorder`` iterator. +There is a special ``[:T]`` syntax when using generics with the method call syntax: + +.. code-block:: nim + :test: "nim c $1" + proc foo[T](i: T) = + discard + + var i: int + + # i.foo[int]() # Error: expression 'foo(i)' has no type (or is ambiguous) + + i.foo[:int]() # Success + Templates ========= |