Created
December 27, 2017 23:17
-
-
Save onelharrison/4af7e36baa7180637b1e5a43155f08d2 to your computer and use it in GitHub Desktop.
Code snippet showing an incorrect attempt to define a private class method in Ruby.
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 Toyota < Car | |
def self.name | |
self.i_am | |
end | |
private | |
def self.i_am | |
"Toyota #{superclass}" | |
end | |
end | |
# => Toyota.name | |
# "Toyota Car" | |
# | |
# => Toyota.i_am # expecting an error | |
# "Toyota Car" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment