Why does this happen?
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 Thing | |
class << self | |
def public_method | |
private_method | |
end | |
private | |
def private_method | |
"hello" | |
end | |
end | |
end | |
Thing.public_method # => "hello" | |
class Thing2 | |
class << self | |
def public_method | |
self.private_method | |
end | |
private | |
def private_method | |
"hello" | |
end | |
end | |
end | |
Thing2.public_method # => NoMethodError (private method `private_method' called for Thing2:Class) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment