From: Morton Goldberg Date: 2007-09-01T02:39:42+09:00 Subject: Re: Dispatching when function name is stated as a symbol On Aug 31, 2007, at 4:48 AM, Ronald Fischer wrote: >>> Hence, if >>> x=cb.call >>> causes x to contain [:g2, 25, 'dummy'], I would like to execute >>> g2(25,'dummy') >>> >>> I have not found a convincing way of doing this. >> >> Would this work for you? >> >> def f(&cb) >> x=cb.call >> name = x[0] >> args = x[1..-1] >> send(name, *args); >> end It can made even simpler: def f(&cb) send(*cb.call) end def g1(a,b,c) puts "g1: #{a}, #{b}, #{c}" end def g2(d,e) puts "g2: #{d}, #{e}" end f { [:g1, 1, 2, 3] } # >> g1: 1, 2, 3 f { [:g2, 2, 3] } # >> g2: 2, 3 Regards, Morton