Skip to content

Variables and Types

Nubo provides a clean and expressive type system.

Use the let keyword:

let name = "Martin"
let age = 19
let isAdmin = true

Use const for immutable values:

const VERSION = "1.0.0"
  • int — whole numbers
  • float — decimal numbers
  • booltrue or false
  • string — text values
  • char — single character
  • []T — list of items
  • dict[K, V] — key-value storage
  • fn(...) -> ... — function types
  • struct — custom data types
  • any — any type

Types are inferred when not specified:

let title = "Nubo" // string
let count = 5 // int

Types can be explicitly defined:

let x: int = 5
let y: []string = ["a", "b"]

Custom types using struct:

struct User {
name: string
roles: []string
data: dict[string, int]
}

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
}