Ruby Build an Address Book in Ruby Search Appending Contacts

Henry Miller
Henry Miller
7,945 Points

What is going on???

Task 2 of challenge 1 in the search module is killing me. This seems so simple, what am I doing wrong???

address_book.rb
contact = Contact.new
contact.first_name = "My"
contact.last_name = "Name"

address_book = AddressBook.new
contact = address_book.push()

2 Answers

Bruce Canedy
Bruce Canedy
13,496 Points

step 1 is correct.

address_book = AddressBook.new

remember you created a new object "address_book" that contains an array called "contacts", so you want to add the "contact" you created early into the "contacts" array.

In you example you are assigning a new contact variable.

you need to do the following.

address_book.contacts.push(contact)

Margeaux Spring
Margeaux Spring
34,703 Points

Also, you cannot add "end" or it won't pass