The pop() function in Ruby is used to pop or remove the last element of the given array and returns the removed elements.
Elements : This is the number of elements which are to be removed from the end of the given array. If this parameter is not used then it removes and returns the single last element of the given array.
Returns: the removed elements.
7 [5, 6] [2, 3, 4] 
g ["f"] ["d", "e"] ["a", "b", "c"] 
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.