From: ara.t.howard@... Date: 2006-03-08T11:02:49+09:00 Subject: Re: Passing the same argument(s) to several methods at once On Wed, 8 Mar 2006, [ISO-8859-1] Iv�n Vega Rivera wrote: > > On 3/7/06, ara.t.howard@noaa.gov wrote: >> >> the general case is: >> >> %w( function_a function_b ).each{|m| receiver.send(m, *args, &block)} >> >> works for any number of args, any receiver, and any block or lack of. >> >> hth. >> >> -a > Thanks but could you explain me a little bit more how that works? Ruby > says 'block' is undefined. So I'm missing something. > > The problem is I don't quite understand how that code works :-) > > Ivan V. a method that takes a block will/can have this signature def m(*args, &block) end here is the simplest possible example: harp:~ > cat a.rb require 'yaml' def a x y "a" => {"x" => x} end def b x y "b" => {"x" => x} end %w( a b ).each{|m| send m, 42} harp:~ > ruby a.rb --- a: x: 42 --- b: x: 42 get a copy of 'the ruby way', the 'pickaxe', or google this group to learn about blocks. kind regards. -a -- judge your success by what you had to give up in order to get it. - h.h. the 14th dali lama