Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,631 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: