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

stuck, contact list task 2

sais task 1 is not anymore passing while nothing changed in code of task 1.

this is the code I wrote. contact_list = []

contact = {"name" => "", "phone_number" => "" } contact['name'] = get_name conact['phone_number'] = get_phone_number

contact.rb
contact_list = []

contact = {"name" => "", "phone_number" => "" }
contact['name'] = get_name
conact['phone_number'] = get_phone_number

1 Answer

Ari Misha
Ari Misha
19,323 Points

Hiya Jesse! The first two tasks are pretty similar. If you've passed the first one , there shouldnt be any issue with second one. In ssecond task, you're gonna have to assign phone_number key of contact hash to another method which is located somewhere in some part of code. Its pretty straightforward and here is my code for the reference for the whole task:

contact_list = []

contact = {"name" => "", "phone_number" => "" }
contact["name"] = get_name
contact["phone_number"] = get_phone_number
contact_list << contact

P.S. : Use double quotes when accessing the values in a hash , not just in Ruby, i mean it for most programming languages coz keys get interpreted as string literals behind the scenes and strings are pretty much immutable. Hence double quotes. Hope it helped!

~ Ari

It seemd that there was an error because task 1 passed with the single quotations but then it failed in task 2. Should of course use the double quotation. Thanks for the help!