Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extending Array with Parallel gem
class Array
%w(each map each_with_index map_with_index flat_map any? all?).each { |meth|
define_method("#{meth}_in_parallel") { |&block|
Parallel.send(meth, self) { |item| block.call(item) }
}
}
}
@mahemoff

This comment has been minimized.

Copy link
Owner Author

commented Jun 29, 2019

Now we can call [1,2,3].each_in_parallel { |i| puts i }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.