From: Dave Thomas Date: 2000-01-11T09:57:52-06:00 Subject: [ruby-talk:01101] Re: Infinite loop matz@netlab.co.jp (Yukihiro Matsumoto) writes: > (b) change the behavior of Array#hash not to traverse items > recursively. e.g. > > def hash > h = self.id > for item in self > h ^= item.id > end > h > end > > Both are real eacy to implement. I prefer latter. class Array def hash h = self.id for item in self h ^= item.id end h end end a = [ 1, 2, 3] p a p a.hash a[0] = 3 a[2] = 1 p a p a.hash Except if you do that, [1, 2, 3] 537680497 [3, 2, 1] 537680497 Shouldn't there be a shift in there? Dave -- Thomas Consulting. Innovative and successful developments with Unix, Java, C, and C++. Now in bookstores: The Pragmatic Programmer. www.pragmaticprogrammer.com/ppbook/