Product SiteDocumentation Site

5.3.6.20. index


>>-index(item)-------------------------------------------------><

Returns the index of the specified item within the array. If the target item appears at more than one index, the first located index will be returned. For multi-dimension arrays, the index is returned as an array of index values. If the array does not contain the specified item, the Nil object is returned. Item equality is determined by using the == method of item.

Example 5.145. Array class - index method

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