Skip to content

Instantly share code, notes, and snippets.

@keiththomps
Created October 6, 2014 20:31
Show Gist options
  • Save keiththomps/c2cf60fcbedd12391498 to your computer and use it in GitHub Desktop.
Save keiththomps/c2cf60fcbedd12391498 to your computer and use it in GitHub Desktop.
Explaining classes
# 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