use Method objects with iterators. : Method objects « Method « Ruby






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