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

dan cornwell
dan cornwell
6,877 Points

what is going on. can you help me with this hash

i just do not understand what they are asking me

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

2 Answers

They asked you to create a variable called final_item that is assigned to a hash consisting of the grocery_item hash merged with the calories hash.

Solution:

  1. google "ruby hash"
  2. Click on the top search result,
  3. Press CTRL + F or CMD + F (for Mac) and search for "merge". Find the merge method documentation.
  4. Use that documentation to figure out how to complete this challenge.

Post back here with your findings. If you still can't do it, explain what you don't understand and someone will help you. Hopefully no-one will just give you the answer straight away.

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

OK. Just a hint. Your last statement is wrong. Your merge is in the wrong place.