Mention UFCS
This commit is contained in:
parent
e793276f2a
commit
c65319376e
1 changed files with 2 additions and 2 deletions
|
|
@ -3,14 +3,14 @@ title: Procs
|
||||||
---
|
---
|
||||||
# Procs
|
# Procs
|
||||||
|
|
||||||
Procedures in Nimrod are declared using `proc` and require that their parameter and return types be annotated. After the types and parameters, an `=` is used to denote the start of the function body.
|
Procedures in Nimrod are declared using `proc` and require that their parameter and return types be annotated. After the types and parameters, an `=` is used to denote the start of the function body. Another thing to note is that procedures have uniform function call syntax, which means that they can called as both `foo(a, b)` or `a.foo(b)`.
|
||||||
|
|
||||||
``` nimrod
|
``` nimrod
|
||||||
proc fibonacci(n: int): int =
|
proc fibonacci(n: int): int =
|
||||||
if n < 2:
|
if n < 2:
|
||||||
result = n
|
result = n
|
||||||
else:
|
else:
|
||||||
result = fibonacci(n - 1) + fibonacci(n - 2)
|
result = fibonacci(n - 1) + (n - 2).fibonacci
|
||||||
```
|
```
|
||||||
|
|
||||||
## Exporting symbols
|
## Exporting symbols
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue