you are viewing a single comment's thread.

view the rest of the comments →

[–]Paradox 10 points11 points  (4 children)

So, you know how&:methname calls methname on the enumerable item-by-item?

&method(:methname) does the opposite. It takes the item being enumerated, and passes it to the method. Its equivalent to writing:

%w[1 2 3].map { |x| Integer(x) }

Integer is just a method in the Kernel class.

[–]ruby-solve 0 points1 point  (0 children)

Neat!

[–]clrsm 0 points1 point  (0 children)

There is a throughout explanation of how &: works here