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 trialShelby Larson
33,317 PointsAssigning Hash values from methods
I cannot figure out how to do this challenge. The question is: Append the contact hash from the contact_list array.
Here is my code
contact_list = []
contact = {"name" => "", "phone_number" => "" }
contact["name"]=get_name()
contact["phone_number"]=get_phone_number()
contact["contact_list"]
2 Answers
Dan Johnson
40,533 PointsIt's wanting you to put the contact hash into the contact_list array. So you could use the push method to append it to contact_list like this:
contact_list.push(contact)
Shelby Larson
33,317 PointsIt worked! Thank you so much
ellie adam
26,377 Pointsit is funny I couldn't pass with () this code worked for me
contact_list.push contact
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsShelby, thanks for the help on getting past the first task, your code really helped me.