Enumerable methods can be chained together to form complex queries. For example, to find the first element in an array that is greater than 5 and less than 10, we can use the following code:
It is expected that each enumerable method passes the block parameters to the next method in the chain. However, this is not the case with Enumerable#many?.
Let’s look at an example at how a similar method, Enumerable#any?, works. Enumerable#any? returns true if an array has at least 1 element. It also accepts any block or parameter passed to it.
When chained with
each_with_index and passed to a block,
it also passes the index parameter as well.
Let’s try something similar with Enumerable#many?.
Clearly, it accepts blocks but no parameters. However when chained with
each_with_index and passed to a block, it does not pass all the parameters.
After this PR Enumerable#many? passes all the parameters to the block.