20,741
edits
m (→Simple examples: experiment ...) |
|||
Line 34: | Line 34: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Functions are | To actually call the function, you can use the '''call()''' API, which expects | ||
* the function name | |||
* a vector with arguments: | |||
<syntaxhighlight lang="nasal"> | |||
var hello = func() { | |||
print("Hello !"); | |||
}; | |||
call( hello,[] ); | |||
</syntaxhighlight> | |||
The '''call()''' API provides the greatest degree of flexibility, because it allows you to directly specify: | |||
* function (func) | |||
* arguments (vector) | |||
* object (me reference/hash) | |||
* namespace (hash) | |||
* vector for list of errors (if any) | |||
But, usually, Functions are just called by appending parentheses to the function name, empty parentheses for function calls without any arguments: | |||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> |