I am trying to make a code with a cat, where you are able to buy certain toys and use them. However, whenever I try to list the toys in the "shop," it gives me an error every time. I'm not sure what I'm doing wrong, but it is definitely somewhere in how I'm executing the command.
class Toy
attr_reader :name
def initialize(name)
@name = name
end
def shop
puts "#{@Toy}"
end
end
toy.shop
I am not sure how to properly run this command, but I'm fairly certain the problem is in the "toy.shop" line.
First of all, this is a class, you should initialize and then call the method like this:
Toy.new('some_toy').shopAnd there is an error in your
shopmethod,@Toydoesn't exists. It should be: