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.rb
address_book = AddressBook.new
def find_ by_phone_number(address_book) 
  results = []
  contacts.each do |contact|
    contact.phone_numbers.each do |phone_number| 
      results.push(contact)
end 

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

address_book.find_by_phone_number("999-999-9999")

Hope that helps.