From: Vahagn Hayrapetyan Date: 2009-09-05T20:10:39+09:00 Subject: Re: how to compare two object instances? is "m1.to_yaml.eql?(m2.to_yaml)" a good way? Have you tried using obj_1.hash == obj_2.hash ? Also, what do you mean by "saving" the object? Persisting it as a byte stream, a string, or in a database using ORM? / Vahagn Greg Hauptmann wrote: > Hi, > > What's an easy way to compare for equality two object instances (that > haven't been saved yet). Or in other words pretty much just two > object instances. I've tried "==" and "eql?" on the objects directly > and this doesn't work. > > How about: "m1.to_yaml.eql?(m2.to_yaml)" Is this the simplest way? > > (i.e. leveraging the ability to serialize the object to a yaml string) > > tks -- Posted via http://www.ruby-forum.com/.