From: Robert Klemme Date: 2003-10-06T23:01:49+09:00 Subject: Re: compare two identically hashes fails "Simon Strandgaard" schrieb im Newsbeitrag news:pan.2003.10.06.13.38.12.369148@sneakemail.com... > On Mon, 06 Oct 2003 16:19:55 +0200, Robert Klemme wrote: > > > > You're welcome. Sometimes expressing one's thoughts is already enough to > > find the answer. :-) > > Yes. > > Some more thoughs about Hash#default... here we go: > > > Why does Hash#inspect not output the content of Hash#default ? > It would make sense, because Ruby already compare Hash#default. In a way it would make sense. On the other hand, the inspect method yields something that can be reconverted to a Hash using eval; although this is likely to work only for standard types (String, Integer, Hash, Array) the feature is quite useful. It would then be reasonable to change the Hash creation syntax, maybe by allowing a single element in front: a = {1=>2, 3=>4} b = {nil 1=>2, 3=>4} c = {"Foo" 1=>2, 3=>4} a == b but a != c > Why does Ruby not reset Hash#default when you issues a #to_hash ? Short answer: why should it? Long answer: Because it returns self. That method is rather meant for other types that can convert themselves to a hash. This method is not expected to generate a side effect and the reset thus would violate POLS. Kind regards robert