Variables and Types
Nubo provides a clean and expressive type system.
Declaring Variables
Section titled “Declaring Variables”Use the let keyword:
let name = "Martin"let age = 19let isAdmin = trueConstants
Section titled “Constants”Use const for immutable values:
const VERSION = "1.0.0"Built-in Types
Section titled “Built-in Types”int— whole numbersfloat— decimal numbersbool—trueorfalsestring— text valueschar— single character[]T— list of itemsdict[K, V]— key-value storagefn(...) -> ...— function typesstruct— custom data typesany— any type
Type Inference
Section titled “Type Inference”Types are inferred when not specified:
let title = "Nubo" // stringlet count = 5 // intType Annotations
Section titled “Type Annotations”Types can be explicitly defined:
let x: int = 5let y: []string = ["a", "b"]Structs
Section titled “Structs”Custom types using struct:
struct User { name: string roles: []string data: dict[string, int]}Functions
Section titled “Functions”Function types are first-class:
let add = fn(a: int, b: int) -> int { return a + b}Or:
fn add(a: int, b: int) -> int { return a + b}