← All examples

Compound change

'i'++;, 'i' += 1; and the others spell change 'i' = 'i' plus 1;, and concat joins text, ++ its symbol.

compound_change.zg
# `'i'++;`, `'i' += 1;` and the others spell `change 'i' = 'i' plus 1;` (owner, 2026-10-14: "we add it
# as an alt"; "(a), they aren't supposed to be used anyways"), and `concat` joins text, `++` its symbol
# (owner: "(a), `concat`"). The long `change` and `concat` are good practice; the symbols are spellings.
# `++` and `--` change a variable only as a whole statement. `/=` and `%=` spell `div.trunc` and `mod.trunc`.
MAIN {
    let mut 'i': int32 = 1;
    change 'i' = 'i' plus 2;         # good practice
    'i' += 2;                        # the same, spelled with a symbol
    'i' *= 3 plus 1;                 # 'i' times (3 plus 1)
    'i'++;
    'i'--;
    'i' **= 2;
    'i' -= 4;
    'i' /= 3;
    'i' %= 5;
    std::print.useful['i', newln];
    std::print.useful["Hello, " concat "Zag", newln];
    std::print.useful["Hello, " ++ "Zag", newln];
}
Output
2
Hello, Zag
Hello, Zag