0

In another answer, I saw an interesting syntax for calling a method on each object in a collection in Rails (or is this really just Ruby?) I tried searching for it but I couldnt find any documentation on it.

reports.map(&:reload)

Is &: an operator? If not, what is it? What is it called? What else can be done with the &: operator?

Community
  • 1
  • 1
Jeff
  • 13,943
  • 11
  • 55
  • 103

1 Answers1

1

&: is called symbol_to_proc

And it is ruby not rails specific

Relevant link

http://pragdave.pragprog.com/pragdave/2005/11/symbolto_proc.html

bjhaid
  • 9,592
  • 2
  • 37
  • 47