Skip to content

07 Functions and explicit returns ​

A named function gives a calculation a reusable input and result.

norm
Integer double(Integer number) {
  return number * 2
}

main() {
  Integer first = double(4)
  Integer second = double(7)

  printLine(first)
  printLine(second)
}

Output:

text
8
14

double declares an Integer parameter and an Integer result. return provides that result to the caller. A call with one argument may omit its label. The two calls share one function body while receiving different values.

Try it: Change the multiplication to addition and predict both output lines.

Precise rules: Language Reference.

Norm 0.25