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

Anterrio Howard
Anterrio Howard
2,625 Points

Now, call the get_phone_number method (which also takes no arguments and returns a string), and assign its return value

Now, call the get_phone_number method (which also takes no arguments and returns a string), and assign its return value to the "phone_number" key of the contact hash

contact.rb
contact_list = []

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

contact = {"name" => "", "phone_number" => "" }

contact['name'] = get_name

contact_list = []

contact = {"name" => get_name(), "phone_number" => "" }
Anterrio Howard
Anterrio Howard
2,625 Points

Here is the question?

In the previous task, we called get_name and assigned its return value to the "name" key of the contact hash.

Now, call the get_phone_number method (which also takes no arguments and returns a string), and assign its return value to the "phone_number" key of the contact hash.

1 Answer

Anterrio Howard
Anterrio Howard
2,625 Points

Found the answer:

contact['phone_number'] = get_phone_number