Ruby | Enumerable drop() function Last Updated : 05 Dec, 2019 Comments Improve Suggest changes Like Article Like Report The drop() of enumerable is an inbuilt method in Ruby returns the rest elements in the enumerator after dropping the first N elements. Syntax: block.drop(N) Parameters: The function takes N which signifies the number of elements to be dropped. Return Value: It returns the rest elements after dropping first N elements. Example 1: Ruby # Ruby program for drop method in Enumerable # Initialize enu = (1..50) # returns rest elements enu.drop(45) Output: [46, 47, 48, 49, 50] Example 2: Ruby # Ruby program for drop method in Enumerable # Initialize enu = [1, 2, 3] # returns rest elements enu.drop(1) Output: [2, 3] Comment More infoAdvertise with us Next Article Ruby | Enumerable drop() function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Enumerable-class Similar Reads Ruby | Enumerable drop_while() function The drop_while() of enumerable is an inbuilt method in Ruby returns an array containing the rest elements after dropping elements up to, but not including, the first element for which the block returns nil or false. In case no block is given it returns the enumerator instead. Syntax: enu.drop_while 1 min read Ruby | Enumerable count() function The count() of enumerable is an inbuilt method in Ruby returns the number of elements in the enumerable, or the number of elements that are equal to a given element, or the number of items which satisfies the condition in the given block. Syntax: block.count { |obj| block } or block.count(element) P 1 min read Ruby | Enumerable all? function The all?() of enumerable is an inbuilt method in Ruby returns a boolean value true if all the objects in the enumerable satisfies the given condition, else it returns false. If a pattern is given, it compares with the pattern, and returns true if all of them are equal to the given pattern, else it r 2 min read Ruby | Enumerable detect() function The detect() of enumerable is an inbuilt method in Ruby returns the first element which satisfies the given condition in the block. If there is no block, then it returns the enumerator itself. Syntax: block.detect { |obj| block } Parameters: The function takes the block according to which the first 1 min read Ruby | Enumerable to_a() function The to_a() of enumerable is an inbuilt method in Ruby returns an array containing all the items of the enumerable. Syntax: enu.to_a() Parameters: The function does not accepts any parameter. Return Value: It returns an array. Example #1: Ruby # Ruby program for to_a method in Enumerable # Initialize 1 min read Ruby | Enumerable collect() function The collect() 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).collect { |obj| block } Parameters 1 min read Ruby | Enumerable entries() function The entries() of enumerable is an inbuilt method in Ruby returns the items in the enumerable. Syntax: enu.entries Parameters: The function does not takes any parameter. Return Value: It returns the items in the enum. Example 1: ruby # Ruby program for entries method in Enumerable # Initialize enu = 1 min read Ruby | Enumerable cycle() function The cycle() of enumerable is an inbuilt method in Ruby calls block for each element of enum repeatedly the given numbers times or forever if none or nil is given. If a negative numbers is given or the collection is empty, it does nothing. It returns nil if the loop has finished without getting inter 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() 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 Like