Ruby Ruby Loops Build a Simple Contact List Assigning Hash Values From Methods

Benjamin Miller
Benjamin Miller
4,344 Points

Can't figure this out.

Not sure why wrong:

contact_list = []

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

Help!

contact.rb
contact_list = []

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

1 Answer

Marco van Vemden
Marco van Vemden
12,553 Points

Hi Benjamin, to append the contact hash to the contact_list array, do:

contact_list << contact