Skip to content

Instantly share code, notes, and snippets.

@Asher-
Forked from banister/query.rb
Created November 2, 2010 05:03
Show Gist options
  • Save Asher-/659270 to your computer and use it in GitHub Desktop.
Save Asher-/659270 to your computer and use it in GitHub Desktop.
# How does work?
# at top-level:
Hello #=> :hello
class Friend
puts Hello
end
#=> NameError: uninitialized constant Friend::Hello
@Asher-
Copy link
Author

Asher- commented Nov 2, 2010

module Test
Hello = "hello"
end
metaclass = class << self ; self ; end
puts metaclass.constants
metaclass.instance_eval do
extend Test
end

class Friend
puts Hello
end

@Asher-
Copy link
Author

Asher- commented Nov 2, 2010

class << self
Hello = "hello"
end
class Friend
puts Hello
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment