Skip to content

Instantly share code, notes, and snippets.

@zgfif

zgfif/program2_animal.rb

Last active Dec 24, 2018
Embed
What would you like to do?
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