The structure of a Gosu program
A Gosu program includes one or more lines that contain Gosu statements. A Gosu program can also include the following elements:
- A metaline
- One or more arguments from the command prompt
- One or more functions
See also
Metaline as first line
Gosu programs support a single line at the beginning of the program for specifying the executable with which to run a file. This line is for compliance with the UNIX standard for shell script files. The metaline is optional. If present, this line must be the first line of the program. The metaline looks like the following:
#!/usr/bin/env gosu
The # character that begins the metaline does not start a comment line in
Gosu programs. The # character is not a valid line-comment start
symbol.
Functions in a Gosu program
Your Gosu program can define functions in the same file and call those functions.
For example, the following program creates a function and calls the function twice:
print(sum(10, 4, 7));
print(sum(222, 4, 3));
function sum(a: int, b: int, c: int) : int {
return a + b + c;
}
Running this program prints:
21
229
