Ruby | Array min() function Last Updated : 06 Dec, 2019 Comments Improve Suggest changes Like Article Like Report Array#min() : min() is a Array class method which returns the minimum value in this array. Syntax: Array.min() Parameter: Array Return: the minimum value in this array. Example #1 : Ruby # Ruby code for min() method # declaring array a = %w[for geeks] # min method example puts "min() method form : #{a.min()}\n\n" puts "min() method form : #{a.min(2)}\n\n" Output : min() method form : for min() method form : ["for", "geeks"] Example #2 : Ruby # Ruby code for min() method # declaring array a = %w[hi I can code for geeks] # min method example puts "min() method form : #{a.min(4)}\n\n" puts "min() method form : #{a.min(1)}\n\n" Output : min() method form : ["I", "can", "code", "for"] min() method form : ["I"] Comment More infoAdvertise with us Next Article Ruby | Array max() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Array-class Similar Reads Ruby | Array max() function Array#max() : max() is a Array class method which returns the maximum value in this array. Syntax: Array.max() Parameter: Array Return: the maximum value in this array. Example #1 : Ruby # Ruby code for max() method # declaring array a = %w[for geeks] # max method example puts "max() method for 1 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 rindex() function Array#rindex() : rindex() is a Array class method which returns the index of the last object in the array. Syntax: Array.rindex() Parameter: Array Return: the index of the last object in the array. if not present then nil Example #1 : Ruby # Ruby code for rindex() method # declaring array a = [18, 2 1 min read Ruby | Array pop() function 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, 1 min read Ruby | Array <=> function Array#() : () is an Array class method which performs the comparison between the two arrays. Syntax: Array.() Parameter: Array for the comparison Return: 1 : if a > b -1 : if a < b 0 : if a = b Example #1 : Ruby # Ruby code for <=>() method # checking equality # declaring arrays a = [18, 2 min read Ruby | Array assoc() function The assoc() function in Ruby is used to search through an array of arrays whose first element is compared with the index of the function and return the contained array if match found otherwise return either nil or vacant. Syntax: Array.assoc(Object) Here Array is the array of arrays. Parameters: Obj 2 min read Like