Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVitaliy Vynarchyk
4,962 PointsWhat is wrong with my code?
I have as such error as "ArgumentError: wrong number of arguments (given 1, expected 0)"
module Inventoryable
def stock_count
@stock_count ||= 0
end
def stock_count=(number)
@stock_count = number
end
end
class Shirt
include Inventoryable
attr_accessor :attributes
def initailize(attributes)
@attributes = attributes
end
end
class Pants
attr_accessor :attributes
def initailize(attributes)
@attributes = attributes
end
end
class Accessory
attr_accessor :attributes
def initailize(attributes)
@attributes = attributes
end
end
shirt1 = Shirt.new(name: "TGK", size: "L")
shirt2 = Shirt.new(name: "Harley", size: "XL")
shirt1.stock_count = 10
puts " Shirt 1 stock count : %s" % shirt1.stock_count
puts " Shirt 2 stock count : %s" % shirt2.stock_count
1 Answer
Ari Misha
19,323 PointsHiya there! I think you completely misunderstood the challenge. The challenge says you need to namespace shirt class and pants class in a variable named Treehouse. And all you've to do is wrap both classes in a module named Treehouse. I hope it helped!
~ Ari