From: "Molitor, Stephen L" Date: 2006-04-20T02:01:23+09:00 Subject: Re: Is there an "in" operator in ruby ? Given these declarations: a = [*1..10] b = [2,4,6,8] You can do this: c = a.select {|i| b.include?(i) } c.each {|i| puts i} Or this: a.each {|i| puts i if b.include?(i) } Or this: (a & b).each {|i| puts i } Steve -----Original Message----- From: list-bounce@example.com [mailto:list-bounce@example.com] On Behalf Of Dinesh Umanath Sent: Wednesday, April 19, 2006 10:46 AM To: ruby-talk ML Subject: Is there an "in" operator in ruby ? Hi all, I want to do this manipulation. I have an array say @test=[2,4,6,8]. How can i compare a given number against the values which are present in this array? ie. In a for loop i will be Iterating through a sequence of number say 1 to 10, and i want to take each of these number 1 to 10 and check if this number is present in the given array @test, if it is present then i want to execute some sequence of steps, How can i do this check in ruby ? Is there a kind of "in" operator in ruby ? Thank You Dinesh -- Posted via http://www.ruby-forum.com/.