Created
August 8, 2012 12:45
-
-
Save stevenbristol/3294839 to your computer and use it in GitHub Desktop.
What is self?
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 Thing | |
def self.log str | |
p str | |
end | |
def test_log | |
begin | |
self.log "does not work" | |
rescue Exception => e | |
p e | |
end | |
Thing.log "this does work A" | |
end | |
self.log "this works B" # => "this works B" | |
log "this works C" # => "this works C" | |
end | |
Thing.new.test_log # => #<NoMethodError: undefined method `log' for #<Thing:0x007fb0fb039db0>> | |
# => "this does work" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment