Created
February 15, 2012 21:19
-
-
Save brainopia/1839064 to your computer and use it in GitHub Desktop.
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
# call methods like constants | |
module Foo | |
def self.bar | |
'tadam' | |
end | |
end | |
Foo::bar # => tadam | |
# methods can be capitalized | |
module Foo | |
def self.Bar(default='boo') | |
default | |
end | |
end | |
Foo.Bar # => "boo" | |
Foo::Bar() # => "boo" - parenthesis are necessary to distinguish from constant | |
Foo::Bar 'yo' # => "yo" | |
# previously it was very popular to have a method with the same name as a class to create a new instance of the class | |
Nokogiri # => Nokogiri | |
Nokogiri 'xml' # => #<Nokogiri::XML::Document:0x3feb951e84c4 name="document"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment