array.push('new element')
# OR
array << 'new element'
a = [ "a", "b", "c" ]
a.push("d", "e", "f")
#=> ["a", "b", "c", "d", "e", "f"]
[1, 2, 3].push(4).push(5)
#=> [1, 2, 3, 4, 5]
array = []
array << "element 1"
array.append "element 2"
puts array
# ["element 1", "element 2"]
array = [1, 2, 3, 4]
array.push(5)
array # => [1, 2, 3, 4, 5]
somearray = ["some", "thing"]
anotherarray = ["another", "thing"]
somearray + anotherarray # => ["some", "thing", "another", "thing"]
somearray.concat anotherarray # => ["some", "thing", "another", "thing"]
somearray.push(anotherarray).flatten # => ["some", "thing", "another", "thing"]
somearray.push *anotherarray # => ["another", "thing", "another", "thing"]
Code Example |
---|
Ruby :: how to create 2 dimensional array in ruby |
Ruby :: shopify: how to show percentage discount saved |
Ruby :: symbol to string ruby |
Ruby :: ruby prepend array |
Ruby :: increment in ruby |
Ruby :: ruby is character |
Ruby :: linked list in ruby |
Ruby :: rails convert image to base64 |
Ruby :: ruby array remove by index |
Ruby :: how to get fields of a table in rails |
Ruby :: ruby create array |
Ruby :: rails server stop pid |
Ruby :: ruby routes |
Ruby :: input must be integer in ruby |
Ruby :: how to update model rails |
Ruby :: string ruby |
Ruby :: ruby if else |
Ruby :: ruby function arguments |
Ruby :: rails migration column types |
Ruby :: ruby do something x times |
Ruby :: run bundle without production in rails |
Ruby :: add several columns rails |
Ruby :: self join relationship rails |
Ruby :: rspec log to console |
Ruby :: rails rspec test email sent |
Ruby :: what is ruby |
R :: harmonic mean in r |
R :: r na omit column |
R :: set row names in r |
R :: R make column of rownames |