On Wed, Nov 12, 2008 at 8:39 AM, Justus Ohlhaver <ohlhaver / gmail.com> wrote:
> Hugh Sasse wrote:
>> On Wed, 12 Nov 2008, 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.
>>
>> What properties do you want the string:integer relationship to have?
>> The problem is too unbounded at the moment.
>>
>> ["Peter", "James", "John", "Andrew"].index("Peter")
>>
>> satisfies the constraints given so far.
>>>
>>> Thanks,
>>> Justus
>>
>>         Hugh
>
> Thanks for your help. No I need to turn the string which would usually
> be a headline ('Man lands on the moon') into a unique number. The
> purpose is to speed up my database queries when checking whether an
> entry with the same headline already exists in the db.
> Justus

Why does it have to be a number?  Your db should already index.

Todd