# Re: Is there an "in" operator in ruby?

**URL:** <https://www.ruby-forum.com/t/re-is-there-an-in-operator-in-ruby/94062>\
**Category:** Ruby\
**Created:** [April 19, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/re-is-there-an-in-operator-in-ruby/94062 "2006-04-19T19:04:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MolitorS\_Stephen\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e480ec/32.png) [@MolitorS\_Stephen\_L](https://www.ruby-forum.com/u/MolitorS_Stephen_L)\
**Post date:** [April 19, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/re-is-there-an-in-operator-in-ruby/94062/1 "2006-04-19T19:04:15Z")

</div>

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
