arrwags
arrwags

Reputation: 78

Chained enumerable methods with enumerable itself as argument

I have an enumerable with several chained methods. I have created a helper method which takes an enumerable and filters out results. The function requires the entire enumerable as its argument instead of being called repeatedly with each element. To illustrate what I am trying to accomplish, please reference the following:

[1,2,3]
.filter { |e| ... }
.map { |e| ... }
.??? { |full_enumerable_as_arg_here| my_filter_function(full_enumerable_as_arg_here) }
.sum

Where ??? would be a chainable method I am not sure exists in Ruby and full_enumerable_as_arg_here representing that I need it to pass the full enumerable generated by .map as opposed to each individual element. I am a ruby novice so please forgive my ignorance, but does something like this exist?

Upvotes: 0

Views: 42

Answers (0)

Related Questions