Skip to content

Instantly share code, notes, and snippets.

@amyhenning
Last active October 27, 2018 22:58
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 amyhenning/ae2d8e6d2c55d7fb34a1e43da311eca1 to your computer and use it in GitHub Desktop.
Save amyhenning/ae2d8e6d2c55d7fb34a1e43da311eca1 to your computer and use it in GitHub Desktop.
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