Created
July 3, 2014 07:37
-
-
Save ozgun/79a9adfd9a4f31d6721f to your computer and use it in GitHub Desktop.
Protected method example
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 A | |
protected | |
def p1 | |
"p1" | |
end | |
end | |
class B < A | |
def m1 | |
p1 | |
end | |
end | |
b = B.new | |
puts b.m1 | |
a = A.new | |
a.p1 # protected method `p1' called for #<A:0x944c240> (NoMethodError) | |
b.p1 # protected method `p1' called for #<B:0x8e04464> (NoMethodError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment