Content deleted Content added
m Fix reference |
m Minor fixes |
||
Line 31:
The following code examples are valid as of Nim 0.10.2. Syntax and semantics may change in subsequent versions.
=== [[Hello world]]
<syntaxhighlight lang="python">
Line 48:
echo "Reversed: ", reverse(str1)
</syntaxhighlight>
This example shows many of Nim's features, one of the most exotic ones is the implicit <code>result</code> variable: every procedure in Nim with a non-void return type has an implicit result variable that represents the value that will be returned. In the for loop we see an invocation of <code>countdown</code> which is an iterator, if an iterator is omitted then the compiler will attempt to use an <code>items</code> iterator if one is defined for the type that was specified in the for loop.
=== Metaprogramming ===
|