Instance method
# delete_at
Deletes an element from self, per the given Integer index.
How to use
Quick guide
Official content
Official how?
I scraped all this data from the official documentation. I created this site to make it easier for beginners and more pleasant for professionals to use Ruby.
Georgie boy
Creator of ruby-docs.org
Deletes an element from
self
, per the given Integer index
.When
index
is non-negative, deletes the element at offset index
: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:a = [:foo, 'bar', 2]
a.delete_at(-2) # => "bar"
a # => [:foo, 2]
If
index
is too small (far from zero), returns nil.
static VALUE
rb_ary_delete_at_m(VALUE ary, VALUE pos)
{
return rb_ary_delete_at(ary, NUM2LONG(pos));
}
Was this page useful?
Leave your feedback
Please hit 'submit' to confirm your feedback.
Leave your feedback
Please hit 'submit' to confirm your feedback.