From: Robert Klemme Date: 2009-05-05T02:15:09+09:00 Subject: Re: String#hash changed in Ruby 1.9? On 04.05.2009 16:48, David Palm wrote: >>> Any tips on how to replace it? >> What does it hurt if the hash value of a string does not remain constant >> between runs of the application? > > In my case it's pretty bad. I use it in a command line utility to cache rake tasks. I create one cachefile for each directory, naming them using the String#hash of the full path (Dir.pwd.hash). If the hash is different the next time the program runs the cache lookup fails (and I get a new cache file instead of the old one). Hm... But you do admit that this is a bit abusive, do you? Especially since there are no guarantees that you won't have any collisions with a hash value like the one returned by #hash. How about storing your cache files with a fixed name in the original directory? Or have a file with metadata (mapping from path to cache file name)? > So, I don't need anything fancy, just an equivalent to Dir.pwd.hash that stay consistent. Do I need to MD5 it? Feels like overkill. Why was this changed in the first place? That's an interesting question. I'm curious as well. Maybe the changes are just a side effect of a new - supposedly better - hashing algorithm. Kind regards robert