Garret Saarinen3,942 Points
Is there a better way that this can be explained? I don't know exactly what this task is asking.
The instructions are- "Append the contact variable to the contacts array inside of the address_book variable."
but everything I write seems to only result in "Task 1 is now failing" so I'm stuck. I don't see a contacts array so I assume I'm supposed to create one to but it isn't very explicate. I initially tried
address_book << contacts
but that doesn't seem it.
contact = Contact.new contact.first_name = "My" contact.last_name = "Name" contacts = Array.new(contact) address_book = AddressBook.new
Paul Jackson7,585 Points
I agree that the question is confusing. If you launch the workspace on video before the challenge it gives some important context as to what you have to work with. The AddressBook class defines a getter for contacts through the attr_reader and it also creates a contacts array in the initialize method like below:
class AddressBook attr_reader :contacts def initialize @contacts =  end end
The attr_reader helper really creates something that looks like this
def contacts @contacts end
This means you access it as a method. So for the challenge, you would need to write something like what's below. You append contact to the instance variable contacts.
contact = Contact.new contact.first_name = "My" contact.last_name = "Name" address_book = AddressBook.new address_book.contacts << contact
Hope this helps ?