Skip to content

Instantly share code, notes, and snippets.

@zgfif
Last active December 24, 2018 11:03
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 zgfif/9412494d684b9029ed8d8477fc76cf29 to your computer and use it in GitHub Desktop.
Save zgfif/9412494d684b9029ed8d8477fc76cf29 to your computer and use it in GitHub Desktop.
Animal
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