Skip to content

Instantly share code, notes, and snippets.

@cwsaylor
Created September 30, 2010 17:56
Show Gist options
  • Save cwsaylor/605013 to your computer and use it in GitHub Desktop.
Save cwsaylor/605013 to your computer and use it in GitHub Desktop.
class AccessPrivate
def a
end
private :a # a is now a private method
def accessing_private
a # sure!
self.a # nope! private methods cannot be called with an explicit receiver at all, even if that receiver is "self"
other_object.a # nope, a is private, you can't get it (but if it was protected, you could!)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment