dave wrote:
> hi list,
>
>
> i've a query string like inname:ruby,opt
>
> the query is splitted in [ 'in', 'name', 'ruby', 'opt']
>
> where 'in' is the name of a function (in-> true|false)
> that look inside an hash for a key 'name' and returns true
> if the value is 'ruby' || 'opt'.
>
>
> hashes are in an array called list.
> i would delete from the list array who doesn't match
> the query.
>
> -----------
>   list.delete_if(){
>     d = false
>     tokens.each {|t|  # method, args, object
>       if (! d)
>         d = true if send(t[0].to_sym, t[1], t[2..-1])

You don't need to_sym - a string is ok.

Here you probably need a star - depending on the definition of the named
method.

>       end
>     b

'b' is undefined here.  Is this a typo?  Did you mean to write 'd'?

>     }
>   }
> ---------------
>
> is there a better way?

I'm not really sure what you're at.  The first thing that confuses me is
that your outer block does not have a parameter.  Normally you would have
the current hash as parameter there and would do some evaluation based on
this parameter.  Other than that, you don't need the outer block at all -
your code just evaluates the same condition for each element in list.
This can be much simplified to:

tokens.any? {|meth, name, *args| send(meth, name, args)} and list.clear

If this doesn't help you please give a bit more information so we can
answer your question more appropriately.

Kind regards

    robert