Ruby Ruby Collections Ruby Hashes Working with Hash Keys

Hash ???

what have done wrong here ????

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

3 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 48,713 Points

hash.has_key? returns a boolean value so set your variable equal to that.

can show me want you mean?

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 48,713 Points
hash = { "name" => "Bread", "quantity" => 1, "calories" => 100 }
food = hash.has_key?("calories")

thank you