Let’s say I have a method (which is actually a helper):
def f(x)
x + 1
end
What I want to do is to map it over an enumerable like so:
(1..10).map &f
It’s obviously doesn’t work raising ArgumentError: wrong number of arguments (0 for 1) error. I know that I can call this method in block like so:
(1..10).map {|x| f x }
But it doesn’t look like an elegant solution to me. What else can be done about it?
You could use: