Jhonny
2007-Sep-05 04:45 UTC
was just going through the section15.6 of agile web development PDF but somehow couldn''t understand how actually the & parameter works .
Hi, I was just going through the section15.6 of agile web development PDF but somehow couldn''t understand how actually the & parameter works . Check 15.6 An Extension to Ruby Symbols from agile web development PDF . 15.6 groups = posts.group_by {|post| post.author_id} # Rails has a shorthand notation for this. We could have written this code as groups = posts.group_by(&:author_id) they say that & uses a proc function given below ,but the function is even more confusing. . class Symbol def to_proc Proc.new { |obj, *args| obj.send(self, *args) } end end please do reply back if u have any solutions Thank you Regards, Piyush Gupta 99161-33729 http://ctrlshiftesc.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---