Created
August 14, 2014 13:06
-
-
Save joejag/f530a3814df6dfa8e7d9 to your computer and use it in GitHub Desktop.
Parallel each method for ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def peach(&block) | |
threads = [] | |
self.each do |item| | |
threads << Thread.new do | |
block.call(item) | |
end | |
end | |
threads.each {|t| t.join } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good stuff!
I am using a version that is slightly more concise: