# Array equality question

**URL:** <https://rubytalk.org/t/array-equality-question/34704>\
**Category:** ruby-talk\
**Created:** [22 January 2007 22:40 UTC](https://rubytalk.org/t/array-equality-question/34704 "2007-01-22T22:40:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ball\_Donald\_A\_Jr\_Lib](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@Ball\_Donald\_A\_Jr\_Lib](https://rubytalk.org/u/Ball_Donald_A_Jr_Lib)\
**Post date:** [22 January 2007 22:40 UTC](https://rubytalk.org/t/array-equality-question/34704/1 "2007-01-22T22:40:38Z")

</div>

I'm very new to ruby, but note that the order of objects in arrays  
traditionally is significant. Perhaps you want to use sets instead?

- donald

> **···**
>
> > -----Original Message-----  
> > From: Chris McMahon [mailto:christopher.mcmahon@gmail.com]  
> > Sent: Monday, January 22, 2007 4:30 PM  
> > To: ruby-talk ML  
> > Subject: array equality question
> > 
> > This took me by surprise:
> > 
> > irb(main):001:0\> a1 = ['x','y','z']  
> > =\> ["x", "y", "z"]  
> > irb(main):002:0\> a2 = ['y','z','x']  
> > =\> ["y", "z", "x"]
> > 
> > irb(main):008:0\> puts "yo" if a1 == a2  
> > =\> nil  
> > irb(main):009:0\> puts "yo" if a1 != a2  
> > yo  
> > =\> nil
> > 
> > I assumed order of elements would not be considered for  
> > equality. Is there any particular reason for this behavior?
