Larzscript Course · Lesson 2 of 15

Variables & Types

Larz covers how Larzscript stores data: declaring with let, five real types with money as its own first-class citizen, reassigning a variable, and dropping values into text with f-strings.

Declaring a variable

Use let. Larzscript infers the type from the value โ€” no annotations to write.

let age = 27
let name = "Larz"
let ready = true
let price_tag = $4.50
let scores = [88, 92, 79]

Five real types

Every value has a real type you can query with type():

print(type(age))       # number
print(type(name))      # string
print(type(ready))     # bool
print(type(price_tag)) # money
print(type(scores))    # list
Output
number
string
bool
money
list

money isn't a number wearing a dollar sign โ€” it's its own real type. That's what let the runtime enforce the require line back in Lesson 1 the same way a type system enforces types.

Reassigning, and f-strings

A let binding isn't locked โ€” reassign with plain =. An f-string drops a variable straight into text with { }:

let coins = 10
print(f"coins: {coins}")
coins = coins + 5
print(f"coins: {coins}")

let is_free = false
if is_free {
    print("free tier")
} else {
    print("paid tier")
}
Output
coins: 10
coins: 15
paid tier

Every snippet on this page is run through the real larzscript interpreter, not hand-typed โ€” what you see in the Output blocks is the actual output.

← Lesson 1Course syllabusLesson 3 →