:=operator. Variables can only be declared this way in V, this means all variables have an initial value. The type of a variable is inferred from the value on the right hand side. By default variables in V are immutable.
Note: Variables can only be defined in a function. There are no global variables and no global state in V.
mutkeyword when declaring the variable. To assign a new value to a variable use
mutkeyword here would result in an error because the value of an immutable variable cannot be changed.
ageis not declared,
age := 21will result in another error while compiling because the variable
ageis already defined in the scope. It's very simple to remember, just declare value with
:=and assign value with
_for ignoring values when it is not needed. Usually used in multi return functions.