Skip to content

Instantly share code, notes, and snippets.

@ozgun
Created July 3, 2014 07:37
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 ozgun/79a9adfd9a4f31d6721f to your computer and use it in GitHub Desktop.
Save ozgun/79a9adfd9a4f31d6721f to your computer and use it in GitHub Desktop.
Protected method example
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