From: James Britt Date: 2005-10-18T11:11:56+09:00 Subject: Re: How do you write an equality method? David Corbin wrote: > Without getting into the details of which equality method (eql?, equal?, ==), > I'm curious about how such a method should be written for class where you're > trying to keep the interface appropriatley private. > > Consider: > > class Foo > def initialize(color) > @color = color > end > . > . > . > end > > If I do not wish to expose color via an attr_reader, how do I write an > equality method for this class? What would make two objects 'equal' ? James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys