--JQ29orswtRjjfiJM
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Ball, Donald A Jr (Library):

> One question for the more advanced rubyists

Let a newbie answer. :) For a similar question, see my =E2=80=98Sane
#hash implementation?=E2=80=99 mail sent just a couple minutes ago.

> I use sets in one place, and tried to unit test the results, but
> Set.=3D=3D didn't perform as I would have expected... for instance:

Set#=3D=3D performs as advertised.

>> Set.new =3D=3D Set.new
=3D> true
>> Set.new([1,2]) =3D=3D Set.new([1,2])
=3D> true

> require 'set'
> s1 =3D Set.new
> s1 << {1=3D>2}
> s1 << {2=3D>3}
> s2 =3D Set.new
> s2 << {1=3D>2}
> s2 << {2=3D>3}
> s1 =3D=3D s2

> is false.

> I thought that since Hash defines values-based =3D=3D,
> Set.=3D=3D would use it, but it appears not.

Set#=3D=3D docs say, =E2=80=98the equality of each couple of elements
is defined according to Object#eql?,=E2=80=99 and seem to be right:

>> Hash.new({1=3D>2}).eql? Hash.new({1=3D>2})
=3D> false

-- Shot
--=20
When you need a helpline for breakfast cereals, it's
time to start thinking about tearing down civilisation
and giving the ants a go.           -- Chris King, asr

--JQ29orswtRjjfiJM
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFFvnvHi/mCfdEo8UoRAvH4AKC+ng2K36t0cKatFhYHPyT8Gcx7yQCfciuV
eGE4W9sJrKACWnJAtdjbPEw=
=Qxw5
-----END PGP SIGNATURE-----

--JQ29orswtRjjfiJM--

Ball, Donald A Jr (Library):

> One question for the more advanced rubyists

Let a newbie answer. :) For a similar question, see my °∆Sane
#hash implementation?°« mail sent just a couple minutes ago.

> I use sets in one place, and tried to unit test the results, but
> Set.== didn't perform as I would have expected... for instance:

Set#== performs as advertised.

>> Set.new == Set.new
=> true
>> Set.new([1,2]) == Set.new([1,2])
=> true

> require 'set'
> s1 = Set.new
> s1 << {1=>2}
> s1 << {2=>3}
> s2 = Set.new
> s2 << {1=>2}
> s2 << {2=>3}
> s1 == s2

> is false.

> I thought that since Hash defines values-based ==,
> Set.== would use it, but it appears not.

Set#== docs say, °∆the equality of each couple of elements
is defined according to Object#eql?,°« and seem to be right:

>> Hash.new({1=>2}).eql? Hash.new({1=>2})
=> false

-- Shot
-- 
When you need a helpline for breakfast cereals, it's
time to start thinking about tearing down civilisation
and giving the ants a go.           -- Chris King, asr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFFvnvHi/mCfdEo8UoRAvH4AKC+ng2K36t0cKatFhYHPyT8Gcx7yQCfciuV
eGE4W9sJrKACWnJAtdjbPEw=
=Qxw5
-----END PGP SIGNATURE-----