Functions - ArdaOzcan/Boink GitHub Wiki
Table of Contents
Functions
Definition
You can declare and define a function using the fn
keyword, then the name of the function and then a list of
argument declarations inside parenthesis. After the
declaration, you must define a body for the function.
Every statement is separated by a new line and the
body ends with a semi colon. (see Syntax Rules)
import io
fn printInfo(string msg)
io.writeLine("INFO: " + msg)
;
Giving
About
giving in Boink is what is called returning in other languages.
Usage
You can declare a give type using the arrow operator (->), if no give type
was declared, the function doesn't have a give type (much like a void function in C).
There are 2 rules:
- If a function has a give type, it must give at some point.
- If a function doesn't have a give type, it can't return.
import io
fn input(string prompt) -> string
io.write(prompt)
give io.readLine()
;