Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Inline Identifiers

In some cases, the parameter name is already included in the argument expression. If there is only one (or multiple identical) identifier(s) within an expression and it matches a parameter of the same type, that parameter will be automatically matched.

test

fn f(x: Integer, y: Integer) -> Integer { x * y }
x = 1;
f(x, y = 2); // matches because argument `x` matches the name of parameter `x`

Even when using a more complex expression a unique identifier can match an argument:

test

fn f(x: Integer, y: Integer) -> Integer { x * y }
x = 1;
y = 2;
f(x * 2, y * y); // matches because `x` and `y` match parameter names `x` and `y`

test

fn f(x: Integer, y: Integer) -> Integer { x * y }
x = 1;
y = 2;
f(x * y, y * x); // error: cannot be matched because arguments are not unique.