Saturday, December 25, 2010

Re: [Rails] I sit possible to write it in one line ? Array init + Array loading

On 25 December 2010 15:23, Erwin <yves_dufour@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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate