kernel/core/array.rb
# For a positive index, inserts the given values before
# the element at the given index. Negative indices count 
# backwards from the end and the values are inserted 
# after them.
For a positive index, inserts the given values before
the element at the given index. Negative indices count
backwards from the end and the values are inserted
after them.
For a positive index inserts the given values before the element at the given index . Negative indices count backwards from the end and the values are inserted after them .
def insert(idx, *items)
    return self if items.length == 0
    idx = Type.coerce_to idx, Fixnum, :to_int
    idx += (@total + 1) if idx < 0    
    raise IndexError, "#{idx} out of bounds" if idx < 0
    self[idx, 0] = items   
    self
  end
def insert ( idx , * items ) return self if items . length == 0 idx = Type . coerce_to idx , Fixnum , :to_int idx += ( @total + 1 ) if idx < 0 raise IndexError , "#{idx} out of bounds" if idx < 0 self [ idx , 0 ] = items self end
For a positive index, inserts the given values before
the element at the given index.
For a positive index inserts the given values before the element at the given index .
# Adjust the index for correct insertion # Negatives add AFTER the element # Cheat
idx
<not_specific>
items
<not_specific>