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