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,212 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!