The if statement executes statements based on some conditions.
Example
with console from std:ioif(a <10) console.out("a is smaller than 10")elseif(a is11) console.out("a is 11")elseif(a >11and a <21) console.out("a is greater than 11 and smaller than 21")else console.out("a is "+ a)end
An if block can contain multiple else if block.
Example
with console from std:ioif(condition) console.out("yes")elseif(otherCondition) console.out("maybe")elseif(otherOtherCondition) console.out("maybe not")else console.out("no")end
match block
The match block is similar to a switch block in C languages. Match cases accept lambdas as actions. If multiple match cases evaluate to true, the first match case is invoked, except if specified otherwise (with match all).
Example
with console from std:iolet fruit ="Apple"var action lambda = { _ =>console.print("Variable is of type string")}match all(fruit)"Apple"=>console.out("Apples are really tasty!")fruit.type() is :string => actionend/*Output: Apples are really tasty!Variable is of type string*/match(fruit)"Apple"=> { _ =>console.out("Apples are really tasty!")}fruit.type() is :string => actionend//Output: Apples are really tasty!
The match block is also able to filter objects and lists.
Example
with console from std:iolet person =Person("John", "Doe")let list = {:ok, "Hello world"}funcdoMatch(a)match(a)Person{firstName:"John"} => console.out("Hello, John")//single operations can be written like so {:ok, msg} => console.out(msg) endenddoMatch(person)//Output: Hello, JohndoMatch(list)//Output: Hello world