Created
December 27, 2019 17:01
-
-
Save shugo/a23118ff9344ea0b968cffacb09186ab to your computer and use it in GitHub Desktop.
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
module M1 | |
refine String do | |
def foo | |
"M1#foo" | |
end | |
end | |
end | |
module M2 | |
refine String do | |
def foo | |
"M2#foo" | |
end | |
end | |
end | |
def bar(m, &block) | |
block.using(m) | |
Thread.pass | |
block.call | |
end | |
using Proc::Refinements | |
100.times.map { |i| | |
Thread.new(i.even? ? M1 : M2) { |m| | |
bar(m) { | |
p [m, "x".foo, Module.used_modules] | |
} | |
} | |
}.each(&:join) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment