From: 7stud -- Date: 2009-04-30T19:59:59+09:00 Subject: Re: find if an array has any element present in another arra Charanya Nagarajan wrote: > Hi, > > I have 2 lists > > a=[1,2,3,4] > b=[2,4,6,7,8] > > I want to find if there are any elements present in "a" which are also > present in "b". > I jus wanna "true" or "false" answer if both of the arrays have any > element in common. > > Is there any inbuilt functions like "include?" for this purpose?? > > Thanks in Advance. a=[1,2,3,4] b=[2,4,6,7,8] result = a & b p result puts (a & b).empty? --output:-- [2, 4] false -- Posted via http://www.ruby-forum.com/.