From: Robinson Risquez Date: 2012-05-19T10:28:54+09:00 Subject: Re: Methods as arguments? Bartosz Dziewoński wrote in post #1061310: > You would have to implement def aaa a little differently. > > > If you want to call it as aaa('hello', :world): (note: this is > generally a bad idea) > > def aaa(string, method) > print string > send method > end > > Note the "send" – it call the method whose name is given as argument > on "self"; in this case (with toplevel methods) it will be an implicit > toplevel object. (If either of your methods belonged to some class, > this would stop working – that's why it's a bad idea.) > > > If you want to call it as aaa('hello', method(:world)): > > def aaa(string, method) > print string > method.call > end Thanks!, now the method world is invoked exactly as I wanted, in the aaa method only. With either of two ways (send or call) works perfectly!. Although I prefer to pass the method as an object and then invoke with call. -- Posted via http://www.ruby-forum.com/.