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 trialSalman Akram
Courses Plus Student 40,065 PointsSearching the Address Book - Task 2
I didn't get the question clear to pass this challenge, here's solution.
Challenge Task 2 of 2
In the search method, call the find_by_name, find_by_address, and find_by_phone_number methods with the argument passed >in to the search method. You can assume that these methods are already defined and do not have to write them.
class AddressBook
def search(contact)
end
#methods are already defined and do not have to write them.
end
address_book = AddressBook.new
address_book.find_by_name(contact)
address_book.find_by_address(contact)
address_book.find_by_phone_number(contact)
Any idea? :/
1 Answer
Tim Knight
28,888 PointsSalman,
Read through the question again:
In the search method, call the find_by_name, find_by_address, and find_by_phone_number methods with the argument passed in to the search method. You can assume that these methods are already defined and do not have to write them.
It's asking you to add the calls to those methods within the search method, so your answer would look something like this:
class AddressBook
def search(contact)
find_by_name(contact)
find_by_address(contact)
find_by_phone_number(contact)
end
end
address_book = AddressBook.new
Salman Akram
Courses Plus Student 40,065 PointsSalman Akram
Courses Plus Student 40,065 PointsAh d-oh! I was confused with calling to those method with argument outside class, tried to figure out the solution. Got it now!
Thanks Tim