Skip to content

Instantly share code, notes, and snippets.

@Shmuwol
Last active August 29, 2015 14:23
Show Gist options
  • Save Shmuwol/b3782b03cc3864cbcf9e to your computer and use it in GitHub Desktop.
Save Shmuwol/b3782b03cc3864cbcf9e to your computer and use it in GitHub Desktop.
Class
class Animal
def initialize(animal)
@animal = animal
end
def sound
if @animal == "dog"
"Woof! Woof!"
elsif @animal == "cat"
"Meow!"
elsif @animal == "fox"
"What does the fox say!?"
else
end
end
def loves
if @animal == "dog"
return "Dogs love: Tennis Balls"
elsif @animal == "cat"
return "Cats love: Catnip"
else
end
end
end
cat = Animal.new("cat")
p cat.sound
p cat.loves
dog = Animal.new("dog")
p dog.sound
p dog.loves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment