insert

ary.insert(index, obj...) รข ary
Instance Public methods

Inserts the given values before the element with the given index.

Negative indices count backwards from the end of the array, where -1 is the last element.

a = %w{ a b c d }
a.insert(2, 99)         #=> ["a", "b", 99, "c", "d"]
a.insert(-2, 1, 2, 3)   #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
doc_ruby_on_rails
2015-03-30 17:44:37
Comments
Leave a Comment

Please login to continue.