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 trial

Ruby

Miles Smith
Miles Smith
2,688 Points

Ruby Hashes challenge

Okay so I went to do the first challenge in the Ruby Hashes challenge and I just don't seem to be understanding why my code won't work, it says "Task one failed" when it didn't before, here is a snipper of my code. The question is, Create a key in the grocery_item_1 hash called "name" and set the value of that key to the string "milk". I did see there was a bug topic posted on this, but saw no resolution

grocery_item_1 = Hash.new grocery_item_1 { "name" >= "milk" }

1 Answer

Seth Reece
Seth Reece
32,867 Points

Hi Miles,

Often times I will get an error on the second part of a code challenge saying part one is not passing. This happens when I have a syntax error on part two of the challenge. In your case it looks like you have a couple syntax errors. You have { "name" >= "milk" } instead of { "name" => "milk" }. Also if using a two line declaration you need an = sign between your hash name and key/value pair. When declaring a hash the simplest method would be:

grocery_item_1 = { "name" => "milk" }