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!

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 Working with Hash Keys

FeLiX Leonard
FeLiX Leonard
847 Points

what am I doing wrong?

I need help with this challenge!

hash = { "name" => "Bread", "quantity" => 1, "calories" => 100 }
if hash.has_key?("calories") food = true

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,855 Points

Hey there,

You pretty much have it. You are just missing one small thing.
Have a look at the error you are getting from the Code Checker:

Bummer: SyntaxError: 21d07c7a-c506-4a1e-b21d-66863807db4e.rb:17: syntax error, unexpected end-of-input, expecting keyword_end food = true ^

The part where it states "unexpected end-of-input, expecting keyword_end food = true ^" is telling you that after the assignment for the variable food (where the caret symbol is), you are missing the keyword end. Remember in Ruby, end is needed to close out the if block. Just add that and it's all good!

Nice work! :) :dizzy: