As you can see in these questions, I have to return a Ruby class method twice.
# # 5a. Create a class called Animal that initializes with a color. Create a method in the class called legs that returns 4.
class Animal
def initialize(color)
@color = color
end
def legs
legs = 4
p "My animal has #{legs} legs"
end
end
# 5b. Create a new instance of an Animal with a brown color. Return how the number of legs for the animal object.
p Animal.new('brown')
I don't receive any error messages. The methods just don't return, I've tried "puts" as well, but I must be missing something else.
Thanks!