Storing field values in an Icon record |
|
To set one field f of a record r to a given value v, simply say
r.f := v;
For all practical purposes, a record is stored as a list. Thus, you can also store values in a field by using
r[k] := v;
where r is the record and k is the position
of the field within the record, counting from 1. For example,
assuming you have declared the ``complex'' type (see
`Declaring an Icon record type'),
you could set the imaginary part of a complex number x
to zero either by:
r.i := 0;
or by:
r[2] := 0;