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

Michael Feuerborn
Michael Feuerborn
6,589 Points

Ruby Loops adding contacts Task 1: I may have misunderstood something.

I think I may be misunderstanding the request of the task. I feel I understand the general nature here, but I am clearly missing something.

Looking at what I have done, can anyone help me see what part of the question I may be missing?

contact.rb
contact_list = []
def add_contact
    contact = {"name" => "", "phone_number" => "" }
  contact["name"] = get_name("What is the name?")
  return contact
end

2 Answers

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 23,486 Points

I totally see where you are going with this-- but they want something a little bit simpler. They are asking only for you to update the existing hash contact, and then push it onto the contact list. See below.

Good luck with Ruby it's a really useful language!

contact_list = []

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

contact["name"] = get_name()
contact["phone_number"] = get_phone_number()
contact_list.push(contact)
Michael Feuerborn
Michael Feuerborn
6,589 Points

Doh! I did this to myself a few lessons ago by coding it to get the input referenced too. Thank you so much, Jeff!