Hello Derek,

2010/4/12 Derek Cannon <novellterminator / gmail.com>:
> Hello everyone, another easy question from a beginner: How do you create
> a method to compare two arrays so that if they share at least 1 common
> element it returns true?

Well, you could use exactly the have_common? method I provided to
compare ranges because arrays also have a to_a method (that does
nothing else than returning the array itself)

def have_common?(r1,r2)
 arr = r1.to_a & r2.to_a
 !arr.empty?
end

a = %w(m w f)
b = %w(m w)
c = %w(t r)
have_common?(a,b)
have_common?(a,c)

Cheers,

-- 
JJ Fleck
PCSI1 LycñÆ KlñÃer