On Thu, Apr 15, 2010 at 12:17 PM, John Lane <ruby-forum / jelmail.com> wrote:
> Hello,

>
> But I don't think it is good idiomatic ruby code. Is there a better way
> to write this type of thing ?

I do not reallly understand why you want nil, instead of [], but apart
of this I would do
select{|_,v| v.include? item}.map(&:first)

or if you insist

inject( nil ){ |r,(k,v)|  v.include?( item ) ? (r||[]) << k : r }
> --
> Posted via http://www.ruby-forum.com/.
>
>



-- 
The best way to predict the future is to invent it.
-- Alan Kay