Ruby | Array pop() function Last Updated : 06 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Array#pop() : pop() is a Array class method which checks removes the last element from the array and returns it. Syntax: Array.pop() Parameter: Array Return: removes the last element from the array and returns it. Example #1 : Ruby # Ruby code for pop() method # declaring array a = [18, 22, 33, nil, 5, 6] # declaring array b = [1, 4, 1, 1, 88, 9] # declaring array c = [34, 5, 7] # pop method example puts "pop() method form : #{a.pop()}\n\n" puts "pop() method form : #{b.pop()}\n\n" puts "pop() method form : #{c.pop(2)}\n\n" Output : pop() method form : 6 pop() method form : 9 pop() method form : [5, 7] Example #2 : Ruby # Ruby code for pop() method # declaring array a = ["abc", "nil", "dog"] # declaring array c = [nil, "abc", "nil", "dog"] # declaring array b = ["cow", nil, "dog"] # pop method example puts "pop() method form : #{a.pop(2)}\n\n" puts "pop() method form : #{b.pop(1)}\n\n" puts "pop() method form : #{c.pop(0)}\n\n" Output : pop() method form : ["nil", "dog"] pop() method form : ["dog"] pop() method form : [] Comment More infoAdvertise with us Next Article Ruby | Array pop() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Array-class Similar Reads Ruby | Array map() function Array#map() : map() is a Array class method which returns a new array containing the values returned by the block. Syntax: Array.map() Parameter: Array Return: a new array containing the values returned by the block. Example #1 : Ruby # Ruby code for map() method # declaring array a = [18, 22, 33, 3 2 min read Ruby | Array one?() function Array#one?() : one?() is a Array class method which checks whether the array is having only one array element. Syntax: Array.one?() Parameter: Array Return: true - if array has only one element otherwise return false. Example #1 :Â Ruby # Ruby code for one?() method # declaring array a = [18, 22, 33 1 min read Ruby | Array push() function Array#push() : push() is a Array class method which appends the given object(s) on to the end of this array. Syntax: Array.push() Parameter: Array Return: appends the given object(s) on to the end of this array. Example #1 : Ruby # Ruby code for push() method # declaring array a = [18, 22, 33, nil, 2 min read Ruby | Array pack() function Array#pack() : pack() is a Array class method which returns the contents of arr into a binary sequence according to the directives in aTemplateString Syntax: Array.pack() Parameter: Array Return: the contents of arr into a binary sequence according to the directives in aTemplateString Example #1 : R 1 min read Ruby | Array none?() function Array#none?() : none?() is a Array class method which checks whether the array is empty or not. Syntax: Array.none?() Parameter: Array Return: true - if array has no elements otherwise return false Example #1 : Ruby # Ruby code for none?() method # declaring array a = [18, 22, 33, nil, 5, 6] # decla 1 min read Like