I won’t repeat my question here, but is there are more efficient way to write this?
def recruits_names
names = []
for r in self.referrals do
names << r.display_name
end
return names
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
mapmethod:[Update] As indicated by Staelen in the comments, this example can be shortened even further to:
For the curious, this is because
&callsto_procon the object following it (when used in a method call), andSymbolimplementsto_procto return aProcthat executes the method indicated by the symbol on each value yielded to the block (see the documentation).