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 Input and Output Instance Variable Access

Miles Smith
Miles Smith
2,688 Points

Correct the code below to make the contacts variable an instance variable.

Hey guys i get the error saying the "@" symbol turns my code into an instance variable, but isn't that whats being asked of me to find?

address_book.rb
class AddressBook
  attr_reader :contacts

  def initialize
    @contacts
  end
end

1 Answer

Hi Miles,

I think you may have just inadvertently deleted the variable assignment:

class AddressBook
  attr_reader :contacts

  def initialize
    @contacts =[]
  end
end

Best, Cena