Memory and locals
Memory
memory hasPower: bool = startsPowered "Power"
memory rang: int = 0 "Rings today"
memoryis the instance's lasting state: it changes in transactions, it is saved, and a world opened again goes on from it.- Its label names it in the editor and in Play's Objects panel.
- The initial value is computed once, when the instance is first set up; it must be a pure expression of literals and properties.
was "oldName"carries the old name's value over in a migration (Saving and migration).
Memory belongs to its script; other scripts cannot see it. A value others need goes into a contract field.
Local variables
let total = business.visitors + 1 // immutable, type inferred
var count = 0 // mutable
var left: int = rings // type written
letis immutable,varmutable; without a type, the type comes from the value.- Both are local to their block and to each turn of a loop.
- A local cannot have the name of anything at the script's level or in the standard library (Names).