Ruby | Enumerable minmax() function Last Updated : 19 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The minmax() of enumerable is an inbuilt method in Ruby returns an array containing two elements. It contains the minimum and the maximum value in the enumerable. The first form assumes all objects implement Comparable whereas the second uses the block to return a b. Syntax: enu.minmax { |a, b| block } Parameters: The function takes an optional block. Return Value: It returns an array containing the minimum and maximum. Example 1: javascript # Ruby program for minmax method in Enumerable # Initialize enu1 = (2..6) # Prints enu1.minmax Output: [2, 6] Example 2: javascript # Ruby program for minmax method in Enumerable # Initialize enu1 = (1..100) # Prints enu1.minmax {|a, b| a<=>b} Output: [1, 100] Comment More infoAdvertise with us Next Article Ruby | Enumerable minmax() function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Enumerable-class Similar Reads Ruby | Enumerable minmax_by() function The minmax_by() of enumerable is an inbuilt method in Ruby returns an array containing two elements. It contains the minimum and the maximum value in the enumerable according to the condition in the block. Syntax: enu.minmax_by { |obj| block } Parameters: The function takes an optional block. Return 1 min read Ruby | Enumerable min() function The min() of enumerable is an inbuilt method in Ruby returns the minimum elements or an array containing the minimum N elements in the enumerable. When no block is given, it assumes all elements to be self comparable, but when the block is given then it is compared using . Syntax: enu.min(n) { |a, b 1 min read Ruby | Enumerable max() function The max() of enumerable is an inbuilt method in Ruby returns the maximum elements or an array containing the maximum N elements in the enumerable. When no block is given, it assumes all elements to be self comparable, but when the block is given then it is compared using . Syntax: enu.max(n) { |a, b 1 min read Ruby | Enumerable map() function The map() of enumerable is an inbuilt method in Ruby returns a new array with the results of running block once for every element in enum. The object is repeated every time for each enum. In case no object is given, it return nil for each enum. Syntax: (r1..r2).map { |obj| block } Parameters: The fu 1 min read Ruby | Enumerable min_by() function The min_by() of enumerable is an inbuilt method in Ruby returns an array of minimum elements which satisfies the condition of the given block. It returns an enumerator when no block is given. Syntax: enu.min_by(n) { |obj| block } Parameters: The function takes two parameters n and block. N signifies 1 min read Ruby | Enumerable max_by() function The max_by() of enumerable is an inbuilt method in Ruby returns an array of maximum elements which satisfies the condition of the given block. It returns an enumerator when no block is given. Syntax: enu.max_by(n) {|obj| block} Parameters: The function takes two parameters n and block. N signifies t 1 min read Ruby | Enumerable none?() function The none?() of enumerable is an inbuilt method in Ruby returns a boolean value true if none of the objects in the enumerable satisfies the given condition, else it returns false. It compares all the elements with the pattern and returns true if none of them matches with the pattern. Syntax enu.none? 2 min read Ruby | Enumerable member? function The member?() of enumerable is an inbuilt method in Ruby returns a boolean value. It returns true if the enumerable contains the given elements, or else it returns false. Syntax: enu.member?(el) Parameters: The function takes an element which is to be checked for. Return Value: It returns a boolean 1 min read Ruby | Enumerable include?() function The include?() of enumerable is an inbuilt method in Ruby returns a boolean value. It returns true if the enumerable contains the given elements, or else it returns false. Syntax: enu.include?(el) Parameters: The function takes an element which is to be checked for. Return Value: It returns a boolea 1 min read Ruby | Enumerable find_index() function The find_index() of enumerable is an inbuilt method in Ruby returns the index of the item which returns true for the given condition in the block, or the index of the item which is equal to the given value. If no block is given, then it returns an enumerator. If the values is not present in the enum 1 min read Like