Tagged Union

Union store their component in the same memory space, but only one element can be used at a time

union U {
  int i;
  float f;
  Object o;

#! create an union with field `i` set to `1`
new U(i, 1) => var U u;

<<< u.i >>>;

#! set field f to 2.4
2.4 => u.f;
<<< u.f >>>;

#! this will trigger an invalid access error
<<< u.i >>>;
built with mdr and mdBook
You'll find the source here, Luke! note: privacy guards may interfere with the playground