From: Robert Klemme Date: 2011-12-30T08:26:31+09:00 Subject: Re: What’s the standard way of implementing #hash for value objects in Ruby? On Thu, Dec 29, 2011 at 4:06 PM, Nikolai Weibull wrote: > On Thu, Dec 29, 2011 at 15:52, Gunther Diemant wrote: >> I think you can't access instance variables from a class method, so >> both methods are kinda useless. > > Ugh, that should of course be > > class A >  def hash >     … >  end > end Easy way: class A def hash [@a, @b, @c].hash end end Easiest: # also gives you == and eql? A = Struct.new :a, :b, :c Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/