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

Alicja Dul
Alicja Dul
8,589 Points

Ruby loops. Challenge 1 of 3. I can not do it..

Please, could someone provide me the right answer?

regards

contact.rb
contact_list = []

def get_name
contact = {"name" => "", "phone_number" => "" }
contact['name'] = get_name.value

end

1 Answer

joelearner
joelearner
34,722 Points

Hi Alicja,

You're pretty close. The question in the exercise says the method get_name has already been created somewhere else. The teacher isn't showing the method but we know it exists. So you won't need the def get_name here.

Also, we don't need to specify value for the get_name method. You can truncate that piece of the code and simplify it.

So the only part you have to add should look something like this:

contact['name'] = get_name

Cheers!

Alicja Dul
Alicja Dul
8,589 Points

Thank you! finally...

contact_list = []

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

contact['name'] = get_name