Ruby Build an Address Book in Ruby Class Design Address Book Class

I have the code exactly the same as Jason but mine prints out differently

I have the code exactly the same as Jason but mine prints out all the contact details before printing out contat_list, while Jason's video prints out only contact_list. Why is that? His video output does not seem right to me. I think my output is correct.

This question is in regard to

Build an address book in Ruby / Address book class

Matt Nickele
Matt Nickele
468 Points

can you post your code?

require "./acontact"

class AddressBook attr_reader :contacts

def initialize @contacts = [] end

def print_contact_list puts "Contact List" contacts.each do |contact| puts contact.to_s('last_first') end end end

address_book =

jasmine = jasmine.first_name = "Jasmine" jasmine.last_name = "Frantz" jasmine.add_phone_number("Home", "123-456-789") jasmine.add_phone_number("Work", "432-123-456") jasmine.add_address("Home", "22 Siesta ct", "", "Sarasota", "FL", "34239")



Have you checked your contact.rb file to see if you are still printing the details out at the bottom of the page like he did to test if the instance methods were working?

If you are those commands will automatically run when you require the Contact class in your AddressBook class.

2 Answers

As Ken Jones mentioned, you might be printing on another one of your files. In my case, My address.rb had a few put statements, which were affecting the outcome of this one.

Also! For future reference, use the Markdown Cheatsheet when including code! Makes it easier to read :)

Joshua Paulson
Joshua Paulson
37,085 Points

Watch all Jason's videos at half speed. He's an amazing teacher but tends to type very quickly. Just slow down the video and you'll get it.