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 Searching by Phone Number

Daniel Wise
Daniel Wise
9,119 Points

Not sure how to do this question!

Very confused what to do here. This is so far what I could come up with.

address_book = AddressBook.new
def find_ by_phone_number(address_book) 
  results = []
  contacts.each do |contact|
    contact.phone_numbers.each do |phone_number| 

1 Answer

Hi Daniel,

Call the find_by_phone_number method on the address_book instance and pass it any phone number.

Basically the question is all about "searching" on anything (i.e phone number, address, names, etc), then you just need to call phone number method. It doesn't need you to create extra definition method for this part.

Here's my example:

address_book = AddressBook.new


Hope that helps.