Ruby Build an Address Book in Ruby Search Appending Contacts

I dont understand what it wants me to do

???

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

1 Answer

Maximiliane Quel
PRO
Maximiliane Quel
Pro Student 55,483 Points

Hi Victor,

I am not entirely familiar with the challenge and a bit more context would have helped, but I am guessing from your code snipped above, that you passed the first task and are wondering what the second part is asking you to do?

You have created an object in the first part and saved that object to the variable address_book. At creation it apparently initialised a contacts variable that contains an array. Your second task seems to be to append the contact variable from the top of the code to this array. To do that you have to access the array and then you can push the variable onto it:

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

address_book = AddressBook.new

address_book.contacts << contact

I would agree with you that without seeing the structure of the underlying class, it's not a lot of information to go on.

Matthew Wilkes
Matthew Wilkes
4,809 Points

This proved to be correct as well as:

 address_book.contacts.push(contact)