kernel/common/array.rb
# Deletes the element at the given index and returns
# the deleted element or nil if the index is out of
# range. Negative indices count backwards from end.
Deletes the element at the given index and returns
the deleted element or nil if the index is out of
range. Negative indices count backwards from end.
Deletes the element at the given index and returns the deleted element or nil if the index is out of range . Negative indices count backwards from end .
def delete_at(idx)
    idx = Type.coerce_to idx, Fixnum, :to_int
    idx += @total if idx < 0
    return nil if idx < 0 or idx >= @total
    obj = @tuple.at(@start + idx)
    @tuple.copy_from(@tuple, @start+idx+1, @total-idx-1, @start+idx)
    @tuple.put(@start + @total - 1, nil)
    @total -= 1
    obj
  end
def delete_at ( idx ) idx = Type . coerce_to idx , Fixnum , :to_int idx += @total if idx < 0 return nil if idx < 0 or idx >= @total obj = @tuple . at ( @start + idx ) @tuple . copy_from ( @tuple , @start + idx + 1 , @total - idx - 1 , @start + idx ) @tuple . put ( @start + @total - 1 , nil ) @total -= 1 obj end
Deletes the element at the given index and returns
the deleted element or nil if the index is out of
range.
Deletes the element at the given index and returns the deleted element or nil if the index is out of range .
# Flip to positive and weed out out of bounds # Grab the object and adjust the indices for the rest
idx
<not_specific>