Sebastian Hungerecker
4/26/2009 11:38:00 AM
C=C3=A9sar D=C3=ADaz wrote:
> def hash
> =C2=A0 =C2=A0 StringUtils.nice_slug(self.name, "false").hash
>
> =C2=A0 end
>
> =C2=A0 def eql?(other)
> =C2=A0 =C2=A0 equal =3D false
> =C2=A0 =C2=A0 if StringUtils.nice_slug(self.name, "false").downcase.eql?
> StringUtils.nice_slug(other.name, "false").downcase
> =C2=A0 =C2=A0 =C2=A0 equal =3D true
> =C2=A0 =C2=A0 end
> =C2=A0 =C2=A0 equal
> =C2=A0 end
If two strings are equal except for case your eql? method will return true.=
Or=20
at least it would if it ever got called. But since you don't call downcase =
in=20
the hash method, those two objects will have different hash values and Set=
=20
will never bother to call eql? on them.
In other words: call downcase in the hash method as well and you'll be fine.
HTH,
Sebastian