Skip to content

Instantly share code, notes, and snippets.

@jbodah
Created November 26, 2014 20:21
Show Gist options
  • Save jbodah/f859fa3ffe1c45e94d57 to your computer and use it in GitHub Desktop.
Save jbodah/f859fa3ffe1c45e94d57 to your computer and use it in GitHub Desktop.
ruby contexts
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