Functions are central in Nim. We’ll learn about functions with a few different examples.
To run the program, save it as functions.nim and use the Nim compiler:
There are several other features to Nim functions. One is multiple return values, which we’ll look at next.
Note: In Nim, functions are called procedures (proc). They can have implicit returns for the last expression, unlike Go which requires explicit returns. Nim also uses echo for printing to the console and string interpolation with fmt for formatting strings.