I just read this answer http://stackoverflow.com/questions/1791639/regular-expression-in-ruby-to-convert-uppercase-title-into-lowercase/1792102#1792102.
There is the following line of code
"abc".split(/(\W)/).map(&:capitalize).join
What exactly is &:capitalize
? Before I had put this into irb myself, I would have told you, it's not valid ruby syntax. It must be some kind of Proc
object, because Array#map
normaly takes a block. But it isn't. If I put it into irb alone, I get syntax error, unexpected tAMPER
. Please enlighten me.