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

Don't get what its asking for.

Assign the value of the key name to the return value of the method get_name() in the contact hash. Assume that get_name() returns a string.

contact.rb
contact_list = []

contact = {"name" => "", "phone_number" => "" }
contact = {"name" => "gets_name()"}

2 Answers

You weren't supposed to make a brand-new line of code, but to edit the second line of code.

Also, you are assigning the key name to the actual string gets_name(), not the return value of gets_name.

You are very close, though.

Try this:

contact.rb
contact_list = []
contact = {"name" => gets_name(), "phone_number" => "" }

Good luck! ~alex

Maciej Czuchnowski
Maciej Czuchnowski
36,423 Points

OK, so you almost got it right. This:

contact = {"name" => "gets_name()"}

is wrong for two reasons: 1) you wrote the name of the method as a strong - just get rid of the quotes an leave "name" => "gets_name()". Second thing - you did this in a new line - do it in the line that the challenge already gave you.

Lol answered at about the same time

Thx, very helpful!