Created
May 12, 2015 23:03
-
-
Save jeffrafter/0fd3621d8dc8300ca3fa to your computer and use it in GitHub Desktop.
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
class Thing | |
def say_hi | |
puts "Hi" | |
end | |
end | |
thing = Thing.new | |
thing.say_hi | |
# "Hi" |
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
class Thing | |
private | |
def say_hi | |
puts "Hi" | |
end | |
end | |
thing = Thing.new | |
thing.say_hi | |
NoMethodError: private method `say_hi' called for #<Thing:0x007fcf9d699fa0> | |
from (irb):11 | |
from /Users/njero/.rbenv/versions/2.2.1/bin/irb:11:in `<main>' |
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
class Thing | |
def say_something | |
say_hi | |
end | |
private | |
def say_hi | |
puts "Hi" | |
end | |
end | |
thing = Thing.new | |
thing.say_something | |
# Hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment