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

Assigning 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"]
Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

Shelby, thanks for the help on getting past the first task, your code really helped me.

2 Answers

Dan Johnson
Dan Johnson
40,533 Points

It'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)

It worked! Thank you so much

it is funny I couldn't pass with () this code worked for me

contact_list.push contact