Function definition: Difference between revisions

(→‎{{header|BASIC}}: Added ANSI BASIC.)
Line 2,190:
Parameters are defined within parentheses after the fn token. To specify no parameters, use an empty set of parentheses.
<syntaxhighlight lang="langur">val .multiply = fn(.x, .y) { .x * .y }
.multiply(3, 4)</syntaxhighlight>
 
=== curly braces ===
A function body may use curly braces, but it is not required if it is a single expression.
<syntaxhighlight lang="langur">val .multiply = fn(.x, .y) .x * .y
.multiply(3, 4)</syntaxhighlight>
 
885

edits