Created
June 2, 2013 18:08
-
-
Save chrisfinne/5694324 to your computer and use it in GitHub Desktop.
ruby class vs. instance method
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 Foo | |
>> | |
?> def self.bar | |
>> "i'm a class method" | |
>> end | |
>> | |
?> def bar | |
>> "i'm an instance method" | |
>> end | |
>> | |
?> end | |
=> nil | |
>> Foo.bar | |
=> "i'm a class method" | |
>> f=Foo.new | |
=> #<Foo:0x00000100c18cd8> | |
>> f.bar | |
=> "i'm an instance method" | |
>> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment