import std
main: f() = std#out.println("Hello world!")
main: f() = doingSomething(;; something can be here ;;) ; doing something!
;;
or can be nowhere!
;;
fool: i8 = 2
; or
let fool: i8 = 2
const anotherFool: bool = true
l: f(x: i128): i128 = x^2
mut nonFool: i32 = 1234567890
; or
let mut nonFool: i32 = 1234567890
main: f() = {
fstop ; will stop lambda and return here
}
example: f(): i32 = {
fstop 1 ; return value is required when fstop
}
i8toi128andisizeintegersu8tou128andusizeunsigned integersf8tof128floatboolbooleancharcharacter
Tuple groups multiple types into one type. Example use:
example: f(x: i8): (i8,i8) = (x-2,x+2)
Way of grouping multiple values into one collection. Example use:
example: f(x: char, y: char): [char:2] = [x,y]
Due to our language being null safe there are no pointers that you can see in C/C++ which are nullable. Example use:
main: f() = {
mut x: i32 = 1
example($mut x)
std#out.println("It is now: $x!") ; It is now 2!
}
example: f(x: $mut i32) = x := 2
eachloops through stuffwhileloops as long as it is trueloopinfinite loop
main: f() = {
elements: [char:5] = ['a','b','c','d','f']
each element : elements std#out.println(element)
; now range operator
each int : 1..100 std#out.println(int)
}
main: f() = {
elements: [char:5] = ['a','b','c','d','f']
mut found: bool = false
mut i: i8 = 0
while !found {
if elements[i] == 'd' = found = true
i++
}
std#out.println("Found 'd' on $i place")
}
main: f() = {
mut i: i32 = 0
loop {
std#out.println("Now number is $i")
if i == 100 = stop ; stops loops and blocks of code and returns
i++
}
}
Ability to construct own data. Example use:
stuct Example {
pub x: i32 =2 ; supports default too!
y: $mut char
}
Example.getY: f(): $char = &.y
mut Example.mutateY: f(y: char) = &.y := y