Created
January 18, 2011 18:09
-
-
Save jacegu/784864 to your computer and use it in GitHub Desktop.
An example to show the use of :: the namespace resolving operator in ruby.
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
class MyClass | |
CONSTANT = 'hello world' | |
end | |
puts MyClass::CONSTANT | |
begin | |
puts MyClass.CONSTANT | |
rescue NoMethodError | |
puts 'With dot notation we are sending a message to class MyClass' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment