From: Alex Fenton Date: 2009-02-09T01:30:22+09:00 Subject: Re: how to combine a list of functions with a list of arguments Boris Schmid wrote: > Apologies, I have been out of using ruby for a while, and ran into > trouble when I tried to do the below. What is the normal way to call > apply a list of arguments to a list of functions? > > def f1(n) > puts "f1: #{n}" > end > > def f2(n) > puts "f2: #{n}" > end [:f1, :f2].each do | fun | [1, 2, 3, 4].each { | x | Object.send(fun, x) } end Ruby doesn't have functions, just methods. What look like functions above (a def outside a class body) creates methods in the Object class. "send" is the generic way to call any object's method using a name. It accepts a string or symbol (hence :f1 above) followed by the arguments. a