Feature #11797
closed`Enumerator#with_object` with multiple objects
Description
Sometimes, when working with Enumerator#with_object, I want to keep some additional temporary objects besides the one to return. A use case is as follows (I got this from this StackOverflow question: http://stackoverflow.com/questions/3418123). Suppose I have an enumerator created from an array:
and want to get an array of its repeated elements in the order they are repeated (i.e., appears for the second time):
I can do it using Enumerator#with_object like this:
Here, I am getting the array referred to as a in the block, but besides that, I am using a temporal hash h. I thought it would be nice if Enumerator#with_object accepts one or more objects, pass them individually as block arguments, and returns only the last argument so that I can do this: