Branching with if and else in Nim is straightforward.
To run the program, save it as if_else.nim and use the Nim compiler:
Note that in Nim, you don’t need parentheses around conditions, but indentation is used to define blocks instead of braces. Also, Nim uses and and or instead of && and || for logical operations.
Nim does have a ternary operator-like construct called the “if expression”:
This can be used for simple conditional assignments, similar to the ternary operator in other languages.
In Nim, the mod operator is used for modulus operations instead of the % symbol used in many other languages.