With arrays, << is the operator for pushing an item onto the end of an array. : Push « Array « Ruby






With arrays, << is the operator for pushing an item onto the end of an array.


# You can also use the push method, which is equivalent.

x = []
x << "Word"
puts x

x.push "Word"
puts x

 








Related examples in the same category

1.Blow Your Stack
2.You can add things to the end of the array by pushing data into it
3.Push integer and string to the same array
4.Push an array to another array