Created
February 21, 2012 15:12
-
-
Save britishtea/1876974 to your computer and use it in GitHub Desktop.
Scopes in Ruby
This file contains 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 Namespace | |
class String | |
def a | |
String.inspect | |
end | |
def b | |
::String.inspect | |
end | |
end | |
end | |
instance = Namespace::String.new | |
instance.a # => "Lol::String" | |
instance.b # => "String" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment