Values & Types

Lux has a strong, static type system. The compiler catches type errors before your code runs.

Lux has four basic types:

Basic Types

  • Int - Integers: 42, -7, 0
  • Float - Decimals: 3.14, -0.5
  • String - Text: "hello"
  • Bool - Boolean: true, false

Use let to create variables. Lux infers types, but you can add annotations:

let x = 42           // Int (inferred)
let y: Float = 3.14  // Float (explicit)

Variables are immutable by default. Once set, they cannot be changed. This makes code easier to reason about.

types.lux
Output
// Click "Run" to execute