Hash *needs* rehashing?


(Massimiliano Mirra) #1

I’m using hashes intensively in an archive module. Often h[‘foo’]
returns nil, although `p h shows that value corresponding to ‘foo’ is
there. If I do a f.rehash before accessing the value, everything
works as expected.

So, what is happening here? Do hashes release their `map’ under
certain condition, and it needs to be remade by rehashing?

I’m not attaching a snippet because I’ve not been able to reproduce
this outside the current code, which is too long to post here.

Massimiliano


(ts) #2

So, what is happening here? Do hashes release their `map' under
certain condition, and it needs to be remade by rehashing?

Do you change $= ?

If yes (see [ruby-talk:10850]), you need to use Hash#rehash

Guy Decoux


(Massimiliano Mirra) #3

Yes, it’s exactly that, thank you!

Massimiliano

···

On Wed, Jul 03, 2002 at 11:14:15PM +0900, ts wrote:

So, what is happening here? Do hashes release their `map’ under
certain condition, and it needs to be remade by rehashing?

Do you change $= ?

If yes (see [ruby-talk:10850]), you need to use Hash#rehash