From: David Flanagan Date: 2007-11-15T03:27:30+09:00 Subject: Re: Proc#hash returns different values for same body The hash method works consistently with ==, but both have misleading documentation. I posted about Proc.== on this list back in June. See ruby-core #11401. I would update the documentation for both methods, except that Nobu (on that thread) said that the equality behavior was still subject to change and that procs might become comparable). David Wolfgang N��dasi-Donner wrote: > Hi! > > I recognized a behaviour of Proc#hash that does not follow the description. > > C:\Dokumente und Einstellungen\wolfgang>ri19 Proc#hash > -------------------------------------------------------------- Proc#hash > prc.hash => integer > ------------------------------------------------------------------------ > Return hash value corresponding to proc body. > > C:\Dokumente und Einstellungen\wolfgang>irb19 > irb(main):001:0> proc{}.hash > => 4858639 > irb(main):002:0> proc{}.hash > => 5009407 > irb(main):003:0> proc{42}.hash > => 7717959 > irb(main):004:0> proc{42}.hash > => 36991 > irb(main):005:0> proc{nil}.hash > => 80887 > irb(main):006:0> proc{nil}.hash > => 419431 > irb(main):007:0> exit > > C:\Dokumente und Einstellungen\wolfgang>ruby19 -v > ruby 1.9.0 (2007-11-13 patchlevel 0) [i386-mingw32] > > From my understanding it should return the same value for input lines 1 > and 2, for 3 and 4, and finally for 5 and 6. > > Did I understand something wrong or is this behavior a fault? > > Wolfgang N��dasi-Donner >