Created
November 26, 2014 20:21
-
-
Save jbodah/f859fa3ffe1c45e94d57 to your computer and use it in GitHub Desktop.
ruby contexts
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
String.instance_eval { self } | |
# => String | |
String.class_eval { self } | |
# => String | |
String.singleton_class | |
# => #<Class:String> | |
string = String.new | |
string.instance_eval { self } | |
# => "" | |
string.class_eval { self } | |
# => NoMethodError: undefined method `class_eval' for "":String | |
string.singleton_class | |
# => #<Class:#<String:0x007fc3e43737a0>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment