forked from luna/jorts
23 lines
467 B
Text
23 lines
467 B
Text
import io
|
|
|
|
fn add (int a, int b) -> int {
|
|
a + b
|
|
}
|
|
|
|
// return type is void by default
|
|
fn main () {
|
|
// explicit types, or
|
|
int val = add(2, 2)
|
|
|
|
// type inferred from the functions' return value
|
|
val := add(2, 2)
|
|
|
|
// variables are immutable, however, you can update them with
|
|
// the value of the old one.
|
|
val = val + 1
|
|
|
|
// a shorthand is val++, same for val--.
|
|
|
|
// string interpolation is implicit
|
|
io.puts("2 plus 2 = {val}")
|
|
}
|