eachIndex

.eachIndex() { |index| ... }

Iterates over each index in the array.

This is essentially the same as calling 'array.length().times()', except that if you remove items, this will dynamically adjust to take them into account.

ns.eachIndex() do |index|
    // index value here
end

See also

each - eachMapping