Re: [Rails] Re: problem with select
On 6 December 2011 02:36, gerbdla <gerbdla@gmail.com> wrote:
> Instead this worked. Not sure exactly why the other works and not
> select.
>
> athlete.leagues.collect(&:league_id)
because ".select" returns only those elements that return true to an
evaluation, while ".collect" returns the result of the block passed to
every element. Have a look at the Enumerable and Array api pages.
http://www.ruby-doc.org/core-1.9.3/Enumerable.html
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home