Product SiteDocumentation Site

5.3.6.17. firstItem


>>-firstItem---------------------------------------------------><

Returns the first item in the array or the Nil object if the array is empty.

Example 5.141. Array class - firstItem method

musketeers=.array~of("Porthos","Athos","Aramis"") /* Creates array MUSKETEERS      */
item=musketeers~firstItem                         /* Gives first item in array     */
                                                  /* (Assigns "Porthos" to item)   */

Returns the index of the first item in the array or the Nil object if the array is empty. For multi-dimension arrays, the index is returned as an array of index values.

Example 5.142. Array class - firstItem method

a = .array~of("Mike", "Rick", "Fred", "Rick")
say a~first  -- says: 1
a = .array~of(,"Mike", "Rick")
say a~first  -- says: 2