News flash: I'm going to Australia in February, so this Web site may be switched off at any time.


Retrieving field values from an Icon record

The notation ``r.f'' refers to field f of record r. For example, assuming you have declared the ``complex'' type (as in declaring an Icon record type), you can write the imaginary part of a complex number x using:

    write ( x.i );

Since a record in Icon is functionally identical to a list of the fields, you can also access the nth field of a record f as ``f[n]''.

For example, this expression writes all the fields of a record r:

    every write ( ! r );
See generating the elements of an Icon list for more information about the ``!'' operator.

This ends our Icon tutorial. There are a lot more useful features, though. For more information, see the references for the Icon language.


See also: Using the Icon programming language
Previous: Storing field values in an Icon record

John W. Shipman, john@nmt.edu