Mega Code Archive

 
Categories / Ruby / Method
 

Use Method objects with iterators

def double(a)  2*a  end  mObj = method(:double)  [ 1, 3, 5, 7 ].collect(&mObj) # [2, 6, 10, 14]