From: Todd Benson Date: 2008-10-12T13:57:41+09:00 Subject: Re: Compare Arrays On Sat, Oct 11, 2008 at 10:50 PM, Tj Superfly wrote: > Hey, I just have a quick question about arrays. > > I have two different ones that I would like to compare. > > Example: > > Array 1: cats, dogs, monkeys > > Array 2: cats, fish, dogs, birds, monkeys > > Now, I would like to compare array 2 with array 1 and have it spit out > any words that aren't in both... if that makes sense. > > So what the program should output is fish, monkeys. Hmm. I'm assuming you are looking for ["fish", "birds"], and if you are, do union, then subtract intersection... a = %w( cats dogs monkeys ) b = %w( cats fish dogs birds monkeys ) (a | b) - (a & b) More than two arrays is left as an exercise :) Todd