let name: string = "John"
let age: i32 = 25
let height: f32 = 5.9
let isStudent: bool = true
let numbers: list = [1, 2, 3, 4, 5]
- Integers:
i32,i64 - Floats:
f32,f64 - Boolean:
bool - String:
string - List:
list
fn greet(name: string) -> string {
return "Hello, " + name
}
fn add(a: i32, b: i32) -> i32 {
return a + b
}
let message = greet("Alice")
let sum = add(10, 20)
class Person {
public {
name: string
age: i32
}
public {
fn greet(self) -> string {
return "Hello, my name is " + self.name
}
fn set_age(self, new_age: i32) {
self.age = new_age
}
}
}
let person = Person { name: "Alice", age: 30 }
print(person.greet())
person.set_age(31)
if ( age >= 18 ){
print("Adult")
} else {
print("Minor")
}
let i: i32 = 0
while ( i < 5 ){
print(i)
i = i + 1
}
for (i in ./[0,5,1]) {
print(i)
}
print(args...)- Print values to stdoutprintln(args...)- Print values to stdout with newlinelen(string|list)- Get length of string or listcurrent_time()- Get current timestampto_string(value)- Convert value to stringparse_int(string)- Parse string to integer
+Addition-Subtraction*Multiplication/Division%Modulo!Logical NOT
==Equal!=Not equal>Greater than<Less than>=Greater than or equal<=Less than or equal
&&AND||OR
Single-line comments using //:
// This is a comment
let x: i32 = 42 // End-of-line comment