Note also that if you actually use these as the keys to a hash, you
will get collisions with arrays of strings, which could confuse the
hell out of someone in 6 months time.

On Aug 28, 4:49 pm, Clifford Heath <[email protected]> wrote:
> On 28/08/2009, at 4:39 PM, Sonia Hamilton wrote:
>
> >   def eql?(other)
> >     [name].eql?([other.name])
> >   end
> >   def hash
> >     [name].hash
> >   end
>
> Note that your hash function creates an extra Array, and your eql?  
> creates *two*.
> This is rather slow, and looks completely unnecessary. You should just  
> say:
>
> def eql?(other)
>    name.eql?(other.name)
> end
> def hash
>    name.hash
> end
>
> Clifford Heath.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to