Last active
December 24, 2018 11:03
-
-
Save zgfif/9412494d684b9029ed8d8477fc76cf29 to your computer and use it in GitHub Desktop.
Animal
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 Animal | |
attr_reader :distance | |
def initialize | |
@distance = 0 | |
end | |
def step! | |
@distance += 1 | |
end | |
end | |
animal = Animal.new | |
p animal.distance # => 0 | |
animal.step! | |
p animal.distance # => 1 | |
animal.step! | |
p animal.distance # => 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment