From: Sean O'Halpin Date: 2007-10-20T07:59:09+09:00 Subject: Re: block composition? ------=_Part_5384_6967961.1192834749984 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/19/07, aa wrote: > Nevertheless, I'm still interested to know if anybody has ever > composed different blocks together within the same iteration (and > how). > > Thanks a lot. > AA > > > Do you mean something like this? def search_from(start) search_all proc {|s| s.creation >= start } end def search_to(_end) search_all proc {|s| s.creation <= _end } end def search(start, _end) search_all proc {|s| s.creation >= start }, proc { |s| s.creation <= _end } end def search_all(*blocks) @list.select {|s| blocks.all? { |blk| blk.call(s) } } end Unfortunately, you can't pass more than one block at a time - you have to convert them to procs. Regards, Sean ------=_Part_5384_6967961.1192834749984--