--nextPart9518005.DP6sjhEFFz Content-Type: text/plain; charset tf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Sunday 09 September 2007 12:23:43 pm Ron Green wrote: > Peter Cooper wrote: > > On 9/9/07, Ron Green <rongreen1 / mac.com> wrote: > >> > >> Marcel Molina Jr. wrote: > >> > It should be noted though that String#hash isn't garaunteed to be > >> > unique. > >> > >> Then,again I ask, what is it good for? > > > > > > It's still useful as a hash. Marcel wasn't wrong, but *no* fixed size > > hash > > is "guaranteed" to be unique as that's absolutely impossible, per the > > pigeonhole principle > > (http://en.wikipedia.org/wiki/Pigeonhole_principle). > > String#hash's hash is of a far lower "quality" than that offered by, > > say, > > SHA-1 or SHA-2. > > > > Regards, > > Peter Cooper > > http://www.rubyinside.com/ > > Peter, > If Its not guaranteed to be unique, then it can't be used for identity. > Can you give me an example of how i would use string.hash? Let's put it this way. MD5 and SHA-* hashes aren't *guaranteed* to be unique either. There's just many more cases where strings will share a hash with String#hash as opposed to something like MD5/SHA-*. Hashes are useful for identify strings in hashtables. You use this every time you say something like: foo = {"bar" => "baz"} foo["bar"] # => "baz" HTH, -- Konrad Meyer <konrad / tylerc.org> http://konrad.sobertillnoon.com/ --nextPart9518005.DP6sjhEFFz Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBG5EriCHB0oCiR2cwRAvaaAJ91scTFNpTDfPNUaXzOswwfcyvTjwCgoRBH Qfi/XhKnqsF1CjNQDINtUP8 mM -----END PGP SIGNATURE----- --nextPart9518005.DP6sjhEFFz--