Skip to content

Instantly share code, notes, and snippets.

@koriroys
Created April 13, 2020 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koriroys/6b59bec8713ef0de4e42bf5f3195c960 to your computer and use it in GitHub Desktop.
Save koriroys/6b59bec8713ef0de4e42bf5f3195c960 to your computer and use it in GitHub Desktop.
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