Functions - LieutenantTeaTM/BubbleTea GitHub Wiki
Functions in BubbleTea are very strict. They have the following rules:
- A return type must be known, if no return type is desired it can be given a null return type
- The function must receive the return data
Syntax for functions goes as follows:
fn
IDENTIFIER
(
args
)
->
TYPE
{
BODY
}
By default every BubbleTea program uses main()
but you can user define functions. Functions cannot have an overlapping name with any external function.
Examples:
fn add(x: int, y: int) -> int {
<- x + y;
}
fn say_hi() -> null {
p!("Hi!");
}