Ruby on Rails Sunday, December 26, 2010

With ActiveSupport from Rails it's also possible:
@providers = @authentications.map(&:provider)
--
Thanks, Ivan Povalyukhin

On Dec 25, 7:35 am, Michael Pavling <pavl...@gmail.com> wrote:
> On 25 December 2010 15:23, Erwin <yves_duf...@mac.com> wrote:
>
> > I am always writing it in 2 lines : ( Array init then loading the
> > array )
>
> >    @providers = []
> >    @authentications.map {|authentification| @providers <<
> > authentification.provider }
>
> > Is there any Ruby writing for writing just one line ?
>
>    @providers = @authentications.map { |authentication|
> authentication.provider }

--
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.

No comments:

Post a Comment