Skip to content

10 Argument shorthand ​

A local identifier can stand for its matching parameter label.

norm
Integer remaining(Integer total, Integer completed) {
  return total - completed
}

main() {
  Integer total = 10
  Integer completed = 4
  Integer left = remaining(total, completed)

  printLine(left)
  printLine(remaining(total: 8, completed: 3))
}

Output:

text
6
5

In remaining(total, completed), each identifier matches the parameter at the same position, so the call is equivalent to remaining(total: total, completed: completed). The explicit second call shows the full form. A bare value with a different name is not shorthand.

Try it: Rename the local completed to done and use an explicit label to keep the call valid.

Precise rules: Language Reference.

Norm 0.25