Skip to content

Instantly share code, notes, and snippets.

@koriroys
Created April 13, 2020 16:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Why does this happen?
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