Ruby | Enumerator::new function Last Updated : 06 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The new function in Ruby is used to create a new Enumerator object, which can be used as an Enumerable. Syntax: Enumerator.new Here, Enumerator is an object. Parameters: This function does not accept any parameters. Returns: the new set of values. Example 1: Ruby # Ruby program for Enumerator::new function # Calling the new function fib = Enumerator.new do |y| a = b = 2 loop do y << a a, b = b, a + b end end # Getting the result in an array form p fib.take(10) Output: [2, 2, 4, 6, 10, 16, 26, 42, 68, 110] Example 2: Ruby # Ruby program for Enumerator::new function # Calling the new function fib = Enumerator.new do |y| a = b = 2 loop do y << a a, b = b, a * b end end # Getting the result in an array form p fib.take(4) Output: [2, 2, 4, 8] Comment More infoAdvertise with us Next Article Ruby | Enumerator::new function K Kanchan_Ray Follow Improve Article Tags : Ruby Ruby-Methods Ruby Enumerable-class Similar Reads Ruby | Enumerator each function The Enumerator#each function in Ruby is used to Iterates over the object according to how this Enumerator was constructed and returns the object's values. Syntax: A.each { |key, value| print key + ' = ' + value + "\n" } Here, A is the initialized object. Parameters: This function accepts constituent 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 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 | Enumerator::Lazy#uniq function The uniq function in Ruby is used to find the unique set of elements from the given array. Syntax: xs.uniq Here, xs is a array of elements. Parameters: This function does not accept any parameters. Returns: the new set of unique values. Example 1: Ruby # Initialising an array with blocks as elements 1 min read Like