Final task for boutique inventory improvements

Hallo again!

I’ve just finished the Boutique Inventory Improvements task, and I’m a little confused about the final instructions.

We are asked to refactor total_stock to use the new block shortcut. I really wasn’t sure how best to do that. I tried adding a new field to the OpenStructs like so:

    @items.each { |item| item.stock_num = item.quantity_by_size.values.sum }
    @items.sum(&:stock_num)

but it didn’t feel quite right, and after reviewing the highest rep solutions I still haven’t figured out exactly what the intended solution was.

I do not believe there is an “intended solution”. In other words, the tests themselves do not dictate any specific solution. So this is more of a “understand the use and concept of this syntax”.

Since you have used the “new block syntax” I would count that as at least half done. The rest is left up to you to know that it can be used and what it does.

If you request mentoring for that exercise, though, the mentor that picks up may see your progression, and may understand more of what you have gone through.

The instructions are just wrong I think. It should be asking you to use the method from the openstruct, not the hash. Whereas it’s asking to use the new block syntax. Sorry. PR below.

All concept exercises have an examplar (in this case https://github.com/exercism/ruby/blob/main/exercises/concept/boutique-inventory-improvements/.meta/exemplar.rb), which are what the author was intending the student to write. They’re not displayed for students, but are displayed to mentors, but you can always check them on GitHub if necessary.

Brill, thanks for sorting this iHiD and good point about the Exemplar.rb file!

1 Like