From: Leslie Viljoen Date: 2008-06-28T05:02:46+09:00 Subject: Re: define_method with block On 6/27/08, Sandro Paganotti wrote: > I've re-arranged a bit your code... maybe this way can be more nice-looking: > > module Taikwando > def self.add_warrior(n) > > define_method(n) do |blk| > puts "#{n} fights!" > blk.call > > end > end > > def fight(*names) > names.each do |n| > Taikwando.add_warrior(n) > end > end > > > def moves (fighter,&block) > self.send(fighter,block) > end > end > > include Taikwando > > fight "morpheus", "neo" > moves("neo") do > puts "karate chop!" > end Ok, that's a bit better, thanks! Les