Created
May 22, 2011 02:13
-
-
Save HashNuke/985105 to your computer and use it in GitHub Desktop.
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
> binding | |
#<Binding:0x0000000140aa28> | |
> binding.class | |
=> Binding | |
> respond_to? :binding | |
false | |
> defined? binding | |
"method" | |
> Object.binding | |
NoMethodError: private method `binding' called for Object:Class |
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
msg = "hello" | |
def say | |
puts msg | |
end | |
say | |
# throws NameError since msg is not in scope |
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
msg = "hello" | |
def say(scope) | |
eval "puts msg", scope | |
end | |
say(binding) | |
# prints hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment