-
Notifications
You must be signed in to change notification settings - Fork 0
Language Features
rosalyn edited this page May 6, 2025
·
3 revisions
A function is a often named block of code that accepts multiple values as parameters.
Functions take a fairly familiar approach in MiniScript as they do in other languages. They can be declared as below:
func <function name>(...<parameter name>: <parameter type>) [-> <return type>]
Here is an example of a function:
func sum(input: number[]) -> number {
// ...
}
Functions can be referenced and called by their name with a list of appropriate arguments (ex. sum([1, 2, 3]))
Variables store a value by a name. You can assign a value to a variable via the following:
<variable name> = <value>
If statements allow you to dictate what happens if a certain condition is met. This takes the format of:
if (<condition>) {
<...then>
} else if (<another condition>) {
<...then>
} else {
<...then>
}
The else keyword represents the case where the previous condition was not met.