From: Florian Gross Date: 2004-06-18T23:28:21+09:00 Subject: Re: How to make generic #== method? Moin! Joel VanderWerf wrote: > module ContentEquality > def hash > content.hash > end > > def eql?(other) > content.eql? other.content > end > > def ==(other) > # self.class == other.class and # optional > content == other.content > end > end That's cool, I think I'm going to use it in the future! :) > Another way might be to iterate over a list of instance variables (or > all of 'em, if that's what you want). Hm, maybe a default .content could be provided by the module; it could look like this: module ContentEquality def content instance_variables.map { |name| instance_variable_get(name) } end end Regards, Florian Gross