Add formatting css and reorganize

This commit is contained in:
flaviut 2014-05-31 21:16:18 -04:00
commit 5747e5fa90
21 changed files with 308 additions and 199 deletions

View file

@ -2,19 +2,19 @@
The `result` variable is a special variable that serves as an implicit return variable. This is useful because in most cases, the control flow semantics of the `return` statement are unneeded. `result` is initialized with the default value for a given return type, so the following code starts as `0`, before being initialized to `number`:
~~~ nimrod
``` nimrod
proc `**`(number, power: int): int =
result = number
for i in 1..power:
result *= number
~~~
```
A possible gotcha is declaring a variable called result and expecting it to have the same semantics.
~~~ nimrod
``` nimrod
proc unexpected(): int =
var result = 5
result += 5
echo unexpected() # Prints 0, not 10
~~~
```