-
-
Save practicingruby/3043643 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| class << self | |
| private | |
| def foo | |
| puts "bar" | |
| end | |
| end | |
| foo # outputs bar | |
| end | |
| A.foo # raises an error |
Author
Yes, that's kind of the point of this example: Class private methods are the same as instance private methods. Kind of weird to see you comment on a gist that has no context whatsoever: It's impossible to see what the point of this code was without the accompanying conversation, as is the case for most gists.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A.send :foo #outputs bar :)