How &: works? if it is a method, and where is it defined? It is rails addition to ruby obviously.
Eric Archangel wrote:
How &: works? if it is a method, and where is it defined? It is rails addition to ruby obviously.
http://caboo.se/doc/classes/Symbol.html#M003931
Symbol#to_proc
This is tricky thing to document. It exploits a ruby syntax quirk where prepending a & to a method argument calls "to_proc" on that object in an attempt to make it eligible to be a block.
v.map(&:to_s)
Is the same as:
v.map { |i| i.to_s }