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
| Alias | Meaning |
|---|---|
int | 32-bit signed (default integer) |
float | 64-bit IEEE |
bool | true / false |
text | owned 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.
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.
