You're probably familiar with the following Ruby shorthand ( a is an array):

a.map(&:method)

For example, try the following in irb:

>> a=[:a, 'a', 1, 1.0] => [:a, "a", 1, 1.0] >> a.map(&:class) => [Symbol, String, Fixnum, Float]

The syntax a.map(&:class) is a shorthand for a.map {|x| x.class} .

Read more about this syntax in "What does map(&:name) mean in Ruby?".

Through the syntax &:class , you're making a method call class for each array element.

My question is: can you supply arguments to the method call? And if so, how?

For example, how do you convert the following syntax

a = [1,3,5,7,9] a.map {|x| x + 2}

to the &: syntax?

I'm not suggesting that the &: syntax is better. I'm merely interested in the mechanics of using the &: syntax with arguments.

I assume you know that + is a method on Integer class. You can try the following in irb: