Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

To be useful, persistent variables must be mutated. Persistents can only be mutated in the postlude.

The following statements mutate persistent variables:

  • clear <pvar>. This deletes the persistent variable <pvar>
  • <pvar> := <expr>. This assigns the value of <expr> to the persistent variable <pvar>.

If the persistent variable is bound to a complex data structure (i.e. maps and arrays), <pvar> can contain a hash path referencing part of the structure (see example below). 

Example

always {
  ent:a := 1;
  app:b{"foo"} := 1 + my_var.defaultsTo(0);
  ent:b{["flip", "flop"]} := "this is a string";
  ent:c := null;
  clear ent:a
}
  • No labels