From: Derek Wyatt Date: 2005-03-05T23:37:51+09:00 Subject: Array uniq -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Howdie, I helped a guy out on IRC a couple of days ago and it set me to asking a question. He wanted to uniquify an array, but the natural equality of his objects was not how he wanted to do it. So, this screams out the need for a block, but uniq doesn't accept one. I gave him this solution instead: ~ h = {} ~ a.each { |x| h[x.thing] = x unless h.include?(x.thing) } ~ uniques = h.values Total overkill when the following would be more fun: ~ a.uniq! { |x, y| x.thing == y.thing } or something similar... It seems strange that this hasn't already been done. There must be a good reason... Thoughts? Regs, Derek -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) iD8DBQFCKcQxxPPkePIbSlwRAkoaAKCmSa9CmkbVF/nhHqBV+5g0evPNrQCg6IAa 4E/9mtRXIqn76tkNE3jIQp4= =byG4 -----END PGP SIGNATURE-----