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 Ruby Foundations Methods Class Methods

Tatiana Perry
Tatiana Perry
17,156 Points

confused about the self.find

    def self.find_for(first_name,last_name)
        @accounts.find{|account| account.full_name == "#{first_name} #{last_name}"}
    end

This is confusing since I don't understand the account.full_name part. Is account being used as a method? How is that with out it being defined first

1 Answer

Artem Prytkov
Artem Prytkov
11,932 Points

Your account class has a method full_name, which returns first and last name as a string. Self.find_for looks for an array of accounts for one where account first and last name matches fnction arguments.