Skip to content

Instantly share code, notes, and snippets.

@hannestyden
Created March 18, 2010 18:17
Show Gist options
  • Save hannestyden/336668 to your computer and use it in GitHub Desktop.
Save hannestyden/336668 to your computer and use it in GitHub Desktop.
class C
def pub
:pub
end
protected
def prot
:prot
end
private
def priv
:priv
end
end
c = C.new
c.respond_to?(:pub) # => true
c.respond_to?(:prot) # => true
c.respond_to?(:priv) # => false
c.pub # => :pub
c.prot rescue "is protected" # => "is protected"
c.priv rescue "is private" # => "is private"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment