Ruby | Enumerable include?() function Last Updated : 05 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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 boolean value. Example #1: Ruby # Ruby program for include? method in Enumerable # Initialize enu = [2, 8, 9, 10, 23] # Prints puts enu.include?(8) puts enu.include?(7) Output: true false Example #2: Ruby # Ruby program for include? method in Enumerable # Initialize enu = (20..30) # Prints puts enu.include?(10) puts enu.include?(29) Output: false true Comment More infoAdvertise with us Next Article Ruby | Enumerable include?() function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Enumerable-class Similar Reads 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 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 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 Ruby | Enumerable grep() function The grep() of enumerable is an inbuilt method in Ruby returns an array of elements which contain every (element == pattern), of all the elements in the pattern. If the optional block is not given, then it returns an array containing the elements in that pattern. Syntax: enu.grep(pattern) { |obj| blo 1 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 reject() function The reject() of enumerable is an inbuilt method in Ruby returns the items in the enumerable which does not satisfies the given condition in the block. It returns an enumerator if no block is given. Syntax: enu.reject { |obj| block } Parameters: The function takes a block whose condition is used to f 1 min read Ruby | Enumerable grep_v() function The grep_v() of enumerable is an inbuilt method in Ruby returns an array of elements which contain every (element != pattern). If the optional block is not given, then it returns an array which does not contain the elements in that pattern. Syntax: enu.grep_v(pattern) { |obj| block } Parameters: The 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 partition() function The partition() of enumerable is an inbuilt method in Ruby returns two arrays, one containing the elements of the enumerable which return true, while the other contains the elements which returns false. It returns an enumerator if no block is passed. Syntax enu.partition { |obj| block } Parameters: 1 min read 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 Like