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 trialJared Armes
Courses Plus Student 6,391 PointsNeed help importing a string into a hash
Alright, so I know I need to assign the returned string from the method get_name() to the key, "name." But I can't seem to figure it out. If anything, the thing that I am having the most trouble with while learning is understanding how to apply the syntax. If anyone could take a look at my code and see where I went wrong, I would be thankful.
contact_list = []
contact = {"name" => "", "phone_number" => "" }
contact["name"].push(get_name())
1 Answer
Chase Marchione
155,055 PointsHi Jared,
The challenge is asking for you to provide the name key with the value that the get_name() method returns. Next up, it's the same idea but you'll be doing it for the phone_number key and the value returned from the get_phone_number method. Finally, you'll put the contact hash into the contact_list array through use of the push method (thus, contact gets appended to contact_list.)
contact_list = []
contact = {"name" => get_name(), "phone_number" => get_phone_number()}
contact_list.push(contact)
Hope this helps!
Jared Armes
Courses Plus Student 6,391 PointsJared Armes
Courses Plus Student 6,391 PointsAhhh, thank you! That makes a lot more sense. I suppose I was just confused the challenge's wording.