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 trial

Ruby Ruby Modules Store Inventory Using Modules Stock Counts

What is wrong with the following code? I keep getting an end of input error for line 26 but everything looks correct.

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 initialize(attributes)
        @attributes = attributes
    end
end

Class Pant
    attr_accessor :attributes

    def initialize(attributes)
        @attributes = attributes
    end
end

Class Accessory
    attr_accessor :attributes

    def initialize(attributes)
        @attributes = attributes
    end
end

shirt1 = Shirt.new(name: "MTF", size: "L")
shirt2 = Shirt.new(name: "MTF", size: "M")

shirt1.stock_count = 10

puts "Shirt 1 stock count: %s" % shirt1.stock_count
puts "Shirt 2 stock count: %s" % shirt2.stock_count

2 Answers

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Class is capitalized on lines 20 and 28 - it should be class in lower-case. That's why Ruby isn't expecting an end on line 26.

Thanks again Jay, figured it was something simple.