Reference
Control
If-else
| Input | One conditional argument (a) and two arguments of any type (b and c). The conditional argument must evaluate to a boolean. The other two arguments must evaluate to the same type. |
|---|---|
| Output | If the condition is true, it returns the first argument. Otherwise it returns the second argument. |
Signature
if (a:Boolean)
b:Any
else
c:AnyExample
if (true)
"yes"
else
"no"
// returns "yes"Let
| Input | One or more bindings and a body expression. |
|---|---|
| Output | The result of evaluating the body with bindings in scope. |
Signature
let name1 = expr1, name2 = expr2, ... in bodyExample
let
a = 5,
b = 1
in
a + b // returns 6Try-catch
| Input | Two arguments, which must evaluate to the same type. |
|---|---|
| Output | It returns the first argument unless it evaluates to an error, in which case, it returns the second argument. |
Signature
try(a: Any, b: Any): AnyExample
try(num_div(10, 0), "Division by zero") // returns "Division by zero"