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


Testing an Icon table for the presence of a key

If you try to retrieve an item from a table using a particular key value, and nothing has ever been stored under that value, the result depends on how you created the table (see creating an Icon table).

For example, if you have created the ``dayNumbers'' array (see storing items in an Icon table), this code would stop the program if there is no entry for the day with name ``today'':

    if  / dayNumbers[today]  then
      stop ( "Argh! There's no such day as ",
              today, "!" );

Next: Creating your own record types in Icon
See also: Using the Icon programming language
Previous: Retrieving items from an Icon table

John W. Shipman, john@nmt.edu