Summary
Items can be added to the end of an array by using either push or <<
1
, while unshift will add a new item to the beginning of an array.
1
Arrays are ordered, integer-indexed collections of any object, with indexing starting at 0.
2
A negative index is assumed to be relative to the end of the array.
2
According to
Summary
Arrays are ordered, integer-indexed collections of any object.
Array indexing starts at 0, as in C or Java. A negative index is assumed to be relative to the end of the array—that is, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on.
class Array - Documentation for Ruby 2.0.0
ruby-lang.org
Class : Array - Ruby 2.5.0 ... Array indexing starts at 0, as in C or Java. A negative index is assumed to be relative to the end of the array—that is, an ...
Class: Array (Ruby 2.5.0)
ruby-doc.org
# Ruby code for append() method # adding elements at the end # declaring array a = [ 18 , 22 , 33 , 4 , 5 , 6 ] # declaring array b = [ 5 , 4 , 22 , 1 , 88 , 9 ...
Ruby | Array append() function - GeeksforGeeks
geeksforgeeks.org
In this part of the Ruby tutorial we cover arrays. Arrays are ordered collections of ... Some Ruby array methods end with an exclamation mark. This is a Ruby ...
Ruby arrays - working with arrays in Ruby
zetcode.com