Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build an Address Book in Ruby Search Appending Contacts

Mark Weinberg
Mark Weinberg
3,002 Points

Initialize a variable called address_book set to a new instance of the AddressBook class.

I am having trouble with Challenge Task 1 of 2 which is Initialize a variable called address_book set to a new instance of the AddressBook class. I put in my code down below but I'm not sure what is wrong. Can someone show me the correct code to this challenge?

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

class AddressBook

  def initialize
    address_book
  end



end

3 Answers

Kevin Korte
Kevin Korte
28,149 Points

The class AddressBook has already been created, so all it wants you to do is to create a new variable called address_book and make it equal a Addressbook.new.

Much like the very first line they have you with the contact example.

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

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Mark. I agree with both Kevin and Margeaux (thank you both). I tried creating an AddressBook class myself and it wouldn't pass. Since this class already exists, you just need to create a new instance of the class. Good luck. :)