34,333
edits
Changes
→Push and Popping Array Elements
</pre>
== Push Pushing and Popping Array Elements ==
An array in Ruby can be treated as a last in first out Last In First Out stack where items are ''pushed'' onto and ''popped'' off the array. This is achieved , unsurprisingly, using the ''push'' and ''pop'' methods.
For example we can create an array and then push elements onto it:
</pre>
Note how the elements are popped out of the array, starting with the last to be pushed onto it. Hence the term ''Last In First Out'' (LILOLIFO).
== Ruby Array Comparisons ==