How &: works? if it is a method, and where is it defined?
It is rails addition to ruby obviously.
–
Nibirutech CTO Eric.Archangel
MSN: [email protected]
QQ: 996252
GMAIL: [email protected]
BLOG: http://blog.sina.com.cn/gameloft
How &: works? if it is a method, and where is it defined?
It is rails addition to ruby obviously.
–
Nibirutech CTO Eric.Archangel
MSN: [email protected]
QQ: 996252
GMAIL: [email protected]
BLOG: http://blog.sina.com.cn/gameloft
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 }
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs