Values
A value binding names a value. let makes one that never changes, and var one you can set again:
let fixedNumber = 10
let fixedText = "the quick brown fox"
var value = 10
value = 20
Types
A binding's type comes from its value, so fixedNumber above is an i32 and fixedText a string. You can write
the type yourself, after a colon:
let small : u8 = 200
let ratio : f32 = 0.5
A bare whole number is an i32 and a bare decimal an f64, unless the type you write says otherwise. A number that
doesn't fit its type is refused. Types has the full list.
Assignment
= sets a var, a field or an array's element again. It's a statement, standing on its own line, rather than an
expression with a value of its own:
var total = 0
total = total + 5
total += 5
+=, -=, *=, /= and %= are shorthand for doing the arithmetic and assigning the result.
A block as a value
A block computes a value with return, and its own bindings stay inside it:
let area = {
let width = 6
let height = 7
return width * height
}