Product SiteDocumentation Site

5.3.6.29. put


            +--------+
            V        |
>>-put(item---,index-+-)---------------------------------------><

Makes the object item a member item of the array and associates it with the specified index or indexes. This replaces any existing item associated with the specified index or indexes with the new item. If the index for a particular dimension is greater than the current size of that dimension, the array is expanded to the new dimension size.
Note that the index argument may also be specified as an array of indexes.
Examples:

Example 5.153. Array class - put method

a = .array~new
a~put("Fred", 1) -- a = .array~of("Fred")
a~put("Mike", 2) -- a = .array~of("Fred", "Mike")
a~put("Mike", 1) -- a = .array~of("Mike", "Mike")

do name over a
  say name
end

/* Output would be: */

Mike
Mike