Created
February 28, 2012 04:18
-
-
Save patrickgombert/1929440 to your computer and use it in GitHub Desktop.
Proc eval example
This file contains hidden or 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 Foo | |
class Bar | |
end | |
class Baz | |
def gen_bar | |
return Proc.new { Bar.new } | |
end | |
end | |
end | |
module Example | |
class Bar | |
def gen_bar | |
Foo::Baz.new.gen_bar.call() | |
end | |
end | |
end | |
Example::Bar.new.gen_bar # => <Foo::Bar> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment