Ruby | Enumerable member? function Last Updated : 05 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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 value. Example #1: Ruby # Ruby program for member? method in Enumerable # Initialize enu = [2, 8, 9, 10, 23] # Prints puts enu.member?(8) puts enu.member?(7) Output: true false Example #2: Ruby # Ruby program for member? method in Enumerable # Initialize enu = (20..30) # Prints puts enu.member?(10) puts enu.member?(29) Output: false true Comment More infoAdvertise with us Next Article Ruby | Enumerable member? function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Enumerable-class Similar Reads 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 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 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 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 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 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 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 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 reverse_each() function The reverse_each() of enumerable is an inbuilt method in Ruby returns the elements of the temporary array. The temporary array contains the enumerable in reverse order. It returns an enumerator if no block is given. Syntax: enu.reverse_each { |obj| block } Parameters: The function accepts a block. R 1 min read Like