Ruby Ruby Collections Ruby Hashes Working with Hash Values

"values_at" assignment -Why my codes do not work?

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

hash.rb
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
if grocery_item.has_value?("Bread")
  grocery_item["food"] = true
end
grocery_list = grocery_item.values_at("item")
return grocery_list

2 Answers

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there! You're doing great! But this is neither a method nor a function and as such, does not need a return statement. If I simply erase your last line, your code passes both steps!

Hope this helps! :sparkles:

Thank you, Jenni