From: Jake McArthur Date: 2006-04-20T02:03:26+09:00 Subject: Re: Is there an "in" operator in ruby ? There you go, ruining my moment of self-apparent ingenuity. :P Anyway.... (@test & [*1..10]).each { |item| puts item } - Jake On Apr 19, 2006, at 11:49 AM, Bill Kelly wrote: > From: "Jake McArthur" >> >> If Array was extended with some set theory, things like this would >> be possible: >> @test.intersect([1..10]).each { |item| puts item } > >>> x = [*1..5] > => [1, 2, 3, 4, 5] > >>> y = [*3..7] > => [3, 4, 5, 6, 7] > >>> x & y > => [3, 4, 5] > >>> x | y > => [1, 2, 3, 4, 5, 6, 7] > >>> x - y > => [1, 2] > >>> y - x > => [6, 7] > > > Regards, > > Bill > >