Robert Klemme wrote:
>
> Here's a more efficient variant - using #inject of course :-)
>
> >> opts.inject(nil){|s,(k,v)| v ? (s ? s << " and " : "") << k << "="
<< v :
> >> s}
> => "title=ruby and author=dave and publisher=oreilly"


I prefer this:

opts.to_a.map{|x| x.join('=') if x[1]}.compact.join(' and ')

---->  "title=ruby and author=dave and publisher=oreilly"