Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Implicit
- def my_yield(val, &block)
- b = eval("self", block.binding)
- eigen = class << b; self; end
- b.instance_eval {It = val}
- my_proc = lambda { val }
- eigen.send(:define_method, :_, my_proc)
- yield
- eigen.send(:remove_method, :_)
- end
- end
- class Object
- include Implicit
- end
- def hello
- my_yield(10, &Proc.new)
- end
- hello { puts(It * 2) }
Add Comment
Please, Sign In to add comment