Hugh Sasse wrote:
> On Fri, 16 Sep 2005, Robert Klemme wrote:
>
>>
>> You can also steal the code from RCR 293 for a general solution:
>> http://rcrchive.net/rcr/show/293
>
> Hmm, that's interesting, but I don't get:
>
> code << "def hash() " << fields.map {|f| "self.#{f}.hash" }.join(" ^
> ") << " end\n"
>
> Shouldn't hash return a Fixnum?

Definitely!

> ------------------------------------------------------------
>       Object#hash obj.hash    => fixnum
> ------------------------------------------------------------------------
>       Generates a +Fixnum+ hash value for this object. This function
>       must have the property that +a.eql?(b)+ implies +a.hash ==
>       b.hash+. The hash value is used by class +Hash+. Any hash value
>       that exceeds the capacity of a +Fixnum+ will be truncated
> before being used.
>
> The function above appears to return a string with numbers separated
> by " ^ ".

Nope.  The join appears during code generation and not during evaluation
of the method.  You can easily verify this by printing code after it's
completed. :-)

Kind regards

    robert