Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPeter Ntiamoah
5,738 PointsI am getting an error that says "The `has_value?` method was not called." But I am calling it clearly in my code.
I am stuck. If it's user error can someone please tell me what I'm missing here? Thanks!
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
value_available = grocery_item.has_value?("Bread")
if value_available
grocery_item = { "food" => true }
end
2 Answers
Tyler Maxwell
Courses Plus Student 42,021 PointsHey Peter, you are calling the has_value?
method correctly. You are not assigning a key/value property on a hash correctly in your if
statement. Review how key/value properties are created on a hash in Ruby and you should be good. Good luck. I hope this helps.
Tyler Maxwell
Courses Plus Student 42,021 PointsNo worries, Peter! I know what you mean. I've done my fair share of head bashing! Good luck!
Peter Ntiamoah
5,738 PointsPeter Ntiamoah
5,738 PointsThanks Tyler! I got it working after bashing my head against the wall for a little bit