|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
Procedures and functionsprocIn Nim, a
In Nim, formal parameters are in read-only mode. So inside funcA What is a pure function? A function that has no side effect (doesn't change its environment) and for the same input it always returns the same output. In the example above, func twice(n: int): int = return 2 * n Short formIf the body is just 1 line, you can write the body after the '=' sign: proc hello() = echo "hello world" If the subroutine has no input parameters, you can omit the parentheses: proc hello = echo "hello world" Note: I don't really like this last short form. |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |
||||||||