Skip to content

Instantly share code, notes, and snippets.

@edisonywh
Created November 9, 2018 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edisonywh/9a190a7c1874cd0c9c3806b31a0cb7a4 to your computer and use it in GitHub Desktop.
Save edisonywh/9a190a7c1874cd0c9c3806b31a0cb7a4 to your computer and use it in GitHub Desktop.
class Foo
def self.class_method
puts "This is a class method of #{self}"
end
def an_instance_method
puts "This is an instance method of #{self}"
end
end
Foo.class_method #=> "This is a class method of Foo"
Foo.new.class_method #=> undefined method `class_method' for #<Foo:0x007f83960d2228> (NoMethodError)
Foo.an_instance_method #=> undefined method `an_instance_method' for Foo:Class (NoMethodError)
Foo.new.an_instance_method #=> This is an instance method of #<Foo:0x007f80aa92d150>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment