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 G.
99161-33729