Skip to content

Instantly share code, notes, and snippets.

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| }
Copy link

mahemoff 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