From: dave Date: 2005-06-16T04:22:16+09:00 Subject: Re: code optimpization: delete_if, each, send. > delete_if() passes a parameter to your block yes, sorry i'm very tired today :( this code works and does what i need: --------------- list.delete_if(){|obj| # the list is an array of objects delete = false # delete the obj from the list @tokens.each{|t| # tockens is the splitted query if (! delete) # # func_signs is an hash. # keys are regexp. values are functions name. # if a token matches the regexp we pass it to # the matched funtion value. # @func_signs.each_key(){|k| if (t =~ k) # the calles function split the tocken and # return true if the obj satisfies this part of tocken delete = (! send(@func_signs[k], obj, t)) end } end } delete } ----------------- examples: query = 'inowner:dave' matches /in(.+)/ => 'in' in func_signs hash. if object.owner != 'dave' we must delete this object from the list. i also would add support for or, not operators, (). but this is another story :) tnx, bie. -- >here are more things in heaven and earth, horatio, than are dreamt of in your philosophy.