Hi --

On Fri, 1 Aug 2008, shadowfirebird / gmail.com wrote:

> Someone please correct me if I'm barking up the wrong tree, but the
> block in select wants a function that returns a logical, and grep
> isn't one.
>
> It seems to work if you use include?(), instead, though.
>
> irb(main):004:0> a1 = [ "one", "two", "three" ]
> => ["one", "two", "three"]
> irb(main):005:0> a2 = ["two", "three", "four" ]
> => ["two", "three", "four"]
> irb(main):006:0> a1.find_all{|x| a2.grep(x)}
> => ["one", "two", "three"]
> irb(main):007:0> a1.find_all{|x| a2.grep(x) == true}
> => []
> irb(main):007:0> a1.find_all{|x| a2.include?(x)}
> => ["two", "three"]

See my previous post. #grep and #include? are not the same.


David

-- 
Rails training from David A. Black and Ruby Power and Light:
  *  Advancing With Rails    August 18-21    Edison, NJ
  * Co-taught by D.A. Black and Erik Kastner
See http://www.rubypal.com for details and updates!