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 Pokemon | |
# from here until line 9, we are INSIDE the class | |
# when a Pokemon is created, its name, type, and level must be set | |
def initialize(name, type, level) | |
@name = name | |
@type = type | |
@level = level | |
end | |
end | |
# from here on out, we are OUTSIDE the class | |
pokemon = Pokemon.new("Charmander", "fire", 12) # create a new Pokemon instance | |
puts pokemon.type # won't work because Charmander's state (name, type, level) are all private |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment