From: "Shot (Piotr Szotkowski)" Date: 2009-09-11T00:56:14+09:00 Subject: What’s the best general implementation of custom #hash methods? --Mjqg7Yu+0hL22rav Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, ruby-talk. What=E2=80=99s the best (fast, yet with relatively few cases when equal has= hes are generated for non-eql objects) way to implement a hash method? Is XOR-ing the hashes of an object=E2=80=99s instance variables (assuming t= hat two objects are eql if their ivars are eql) a good general approach? I=E2=80=99m asking because I use this pattern in my code, and it seems quite fast; I needed to work around a bug in MRI=E2=80=99s Set#hash and this solu= tion=C2=B9 seems about as fast as the original MRI=E2=80=99s Set#hash. I=E2=80=99m jus= t not sure whether it=E2=80=99s hashy enough (so to speak) in that two un-eql objects hashed in this way produce different hashes often enough. =C2=B9 http://github.com/Chastell/art-decomp/commit/b465660b9dcc8eada86f50b= bcb8f951aa8145a19 =E2=80=94 Shot --=20 Ill-informed qmail-bashing is better than no qmail-bashing at all. [Don Marti] --Mjqg7Yu+0hL22rav Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqpIZoACgkQi/mCfdEo8UpDpQCeP3ttOJXQLioMVXL0GSFlJBKU e24AoJmbRhF+IRLg9sah1otjWw3rV+3/ =jGk5 -----END PGP SIGNATURE----- --Mjqg7Yu+0hL22rav--