Skip to content
All guides

learn

Numbers, text, and money

Still the ledger. We only add data.

fn main() {
    owner = "Ada"
    mut balance_cents = 0
    deposit = 5000
    balance_cents = balance_cents + deposit
    println(owner)
    println(balance_cents)
}

Everyday types

AliasMeaning
int32-bit signed (default integer)
float64-bit IEEE
booltrue / false
textowned UTF-8: never null

For money, stay on int cents until you have a decimal type you trust.

Immutable vs mut

owner = "Ada"           # cannot reassign
mut balance_cents = 0   # can

That is the whole binding story. No let.

Print

println for text, int, float, or bool. Interpolation for mixed output:

println("{owner} holds {balance_cents} cents")

Next: keep many transactions, not one number: arrays and lists.