From: Stefano Crocco Date: 2008-05-01T23:26:17+09:00 Subject: Re: Ruby exceptions and YAML On Thursday 01 May 2008, Bill Lear wrote: >  I would think that for any ruby object 'obj', the following should > hold: > > obj == YAML::load(YAML::dump(obj)) > > but this seems to not be the case. It depends on the == methods for the class in question. If you try the same using, for example, an array, you'll find that the comparison returns true. This happens because Array redefines the == method defined in class Object, which returns true only if the two operands are the same object. Class Exception, instead, doesn't redefine it, and so the comparison between two exceptions will always return false, unless they're the same object. This means that this will return false: RuntimeError.new('msg') == RuntimeError.new('msg') Since YAML.load creates a new object basing on the contents of its argument, the returned Exception is different (according to ==) from the original. I hope this helps Stefano