Ruby Ruby Collections Ruby Hashes Working with Hash Values

Getting the correct value in a Hash

Hi! I'm trying to pass this challenge:

Using the has_value? method, check to see if the grocery_item hash has a value called "Bread". If it does, set a new key in the hash called "food" with the value of true.

It's telling me that "food" is not returning a value of true. When I run this in irb it works fine. I'm unsure what I might be missing here...

grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
if grocery_item.has_value?("Bread")"food", "true")

1 Answer

true shouldn't be enclosed in quotes. That makes it a string instead of a boolean.