use Method objects with iterators. : Method objects « Method « Ruby
- Ruby
- Method
- Method objects
use Method objects with iterators.
def double(a)
2*a
end
mObj = method(:double)
[ 1, 3, 5, 7 ].collect(&mObj) # [2, 6, 10, 14]
Related examples in the same category