From: Justus Ohlhaver Date: 2008-11-13T00:22:05+09:00 Subject: Re: Convert text string i.e 'Peter' into integer ID Ken Bloom wrote: > On Wed, 12 Nov 2008 08:16:36 -0500, Justus Ohlhaver wrote: > >> Hello, >> >> is there any method to quickly convert a text string such as 'Peter' >> into an integer? (And vice versa?) >> >> I am not asking about just changing the format (to_i). I'm looking for a >> method thus can do the computation. >> >> Thanks, >> Justus > > Does "Peter".hash do what you want? > > --Ken Yes, thanks it seems to do what I need, except for two possible limitations: 1.Accordinng to Sebastian (above) 'Hash values are not unique. Two different strings can have the same hash value' 2.It may not serve my original purpose, which is speeding up database queries. Thanks again, Justus -- Posted via http://www.ruby-forum.com/.