Ruby Ruby Collections Ruby Hashes Working with Hash Keys

Brooke Bachman
Brooke Bachman
353 Points

Why isn't this working?

hash = { "name" => "Bread", "quantity" => 1, "calories" => 100 } hash["calories"]

hash.rb
hash = { "name" => "Bread", "quantity" => 1, "calories" => 100 }
hash["calories"] 

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 50,902 Points

According to the instructions you need to use the has_key? method to check for the "calories" key. If it exists set a new variable food = true.