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 Collections Ruby Hashes Hash Methods

I've watched the video over and over again but still can't seem to get it :-(

can't seem to understand what to do here.

hash.rb
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
calories = { "calories" => 100 } puts hash.merge({ final_item => grocery_item })

1 Answer

Taylor Boudreau
Taylor Boudreau
7,285 Points

Hi there Isaac,

In this case the challenge is asking you to create a new hash, final_item, which is created by merging grocery_item and calories. In this case you won't need to use a puts statement as it's only requesting that you merge the two hashes and nothing needs to be explicitly returned.

Additionally you'll want to call the merge method directly on one of the hashes you're merging. My solution (in addition to the provided code) looked like the following:

final_item = grocery_item.merge(calories)

I hope that helps!

Taylor