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 Ruby Loops Build a Simple Contact List Assigning Hash Values From Methods

kevinthecoder
kevinthecoder
10,791 Points

Unable to solve Challenge get_name

I've been at this stuff for 5 hours straight now (with a 20 minute lunch in-between). I don't know...maybe the braincells aren't working as good as when I first started today? Not sure. In any case....I could use some help on this one. Suggestions?

contact.rb
contact_list = []
def get_name()
contact = {"name" => "", "phone_number" => "" }
  return contact{"name"}
end

3 Answers

Awesome, I love Hash with Key-Values pairs.

Just remember this:

hash = { "key1" => "value1", "key2" => "value2" }


If you are satisfy with the answer above, it is important to note that we suggest you to select "Best Answer" option under the post to let other members know an approval answer that will solve their problems in near future.

Hi Kevin,

Hint: Assign the key name to have value of the method get_name() in the contact hash, that's all we need to do. You just put new value get_name() for name as a key.

Example:

contact_list = []

contact = {"name" => get_name(), "phone_number" => "" }

Next question, you will be asked to put value of the method ____ for phone number. :blush:

-Salman

kevinthecoder
kevinthecoder
10,791 Points

Thank you, Salmon.

Sigh....I can't believe it was soooo simple. ARGH. Sometimes, I really have a hard time interpreting exactly what they are asking.

FYI: after this, I zoomed through the two other challenges with no problems.