End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Array#delete_at
array.delete_at(index) → deleted_object or nil
array.c
View on GitHub ↗
static VALUE
rb_ary_delete_at_m(VALUE ary, VALUE pos)
{
return rb_ary_delete_at(ary, NUM2LONG(pos));
}
Deletes an element from self, per the given Integer index.
When index is non-negative, deletes the element at offset index:
Example
a = [:foo, 'bar', 2] a.delete_at(1) # => "bar" a # => [:foo, 2]
If index is too large, returns nil.
When index is negative, counts backward from the end of the array:
Example
a = [:foo, 'bar', 2] a.delete_at(-2) # => "bar" a # => [:foo, 2]
If index is too small (far from zero), returns nil.