Product SiteDocumentation Site

5.3.6.32. section


>>-section(start-+--------+-)----------------------------------><
                 +-,items-+

Returns a new array (of the same class as the receiver) containing selected items from the receiver array. The first item in the new array is the item corresponding to index start in the receiver array. Subsequent items in the new array correspond to those in the receiver array (in the same sequence). If you specify the whole number items, the new array contains only this number of items (or the number of subsequent items in the receiver array, if this is less than items). If you do not specify items, the new array contains all subsequent items of the receiver array. The receiver array remains unchanged. The section() method is valid only for single-index arrays.
Note that the start argument, (the index argument,) may also be specified as an array of indexes.

Example 5.156. Array class - section method

a = .array~of(1,2,3,4)  -- Loads the array

b = a~section(2)   -- b = .array~of(2,3,4)
c = a~section(2,2) -- c = .array~of(2,3)
d = a~section(2,0) -- d = .array~new