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

Wont tell me why its not working?

I'm I missing something as it looks good to me

contact.rb
contact_list = []

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

contact["name"].push(get_name)

3 Answers

Steve Hunter
MOD
Steve Hunter
Treehouse Moderator 56,087 Points

At the moment, the name attribute has an empty string assigned to it. 'name' => "".

Instead of that, the challenge wants you to use the get_name method so that the 'name' attribute holds what that method returns.

So, instead of 'name' => "" change this to 'name' => get_name. This means that 'name' willl now hold whatever is returned by the method, get_name.

Make sense?

Steve.

I did that only I had "get_name", thank you for clarifying it!

Steve Hunter
Steve Hunter
Treehouse Moderator 56,087 Points

Ah, yes. The method name doesn't require the "" surrounding it. Just call it directly as-is.

Steve Hunter
MOD
Steve Hunter
Treehouse Moderator 56,087 Points

Hi Victor,

I just posted in your other thread about this challenge.

You want to replace the assignment of the empty string, "", with the call to the get_name method. So, delete the "" and replace with get_name.

Steve.

still not following mate

Still not following mate...