Created
October 6, 2014 20:31
-
-
Save keiththomps/c2cf60fcbedd12391498 to your computer and use it in GitHub Desktop.
Explaining classes
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
# How class methods work in ruby | |
class MyClass | |
def self.stuff | |
puts "This is stuff on #{self}" | |
end | |
end | |
MyClass.stuff # => "This is stuff on MyClass" | |
# Same thing written differently... | |
MyOtherClass = Class.new | |
def MyOtherClass.stuff | |
puts "This is stuff on #{self}" | |
end | |
MyOtherClass.stuff # => "This is stuff on MyOtherClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment