From: "Chr. Rippel" Date: 2002-01-31T09:44:52+09:00 Subject: Re: Proc hash bug? wrote in > But that's one of the things I love most about Ruby! The 'method { block > }' syntax is very pleasing to me, so it makes me ask questions when it > doesn't work for my application. At this point, I'm just trying to > understand why the behavior is as it is, and not the way I expect. ... I can see that > .... > Ah, yes, I thought about this. I might end up doing it, or something > like it that uses a wrapper instead of modifying Proc itself. Is there a > more direct way to access the id than using a regular expression? Well looking at the source in eval.c 6567-82 static VALUE proc_to_s(self, other) VALUE self, other; { struct BLOCK *data; char *cname = rb_class2name(CLASS_OF(self)); VALUE str; Data_Get_Struct(self, struct BLOCK, data); str = rb_str_new(0, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:nul */ sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", cname, data->tag); RSTRING(str)->len = strlen(RSTRING(str)->ptr); if (OBJ_TAINTED(self)) OBJ_TAINT(str); return str; } it should not be hard to write this as an extension - actually its probably not such bad idea to write up an RCR (there was a similar situation about #== I believe) . Using data->tag as a hash value seems save to me - anyway for now you also could(should) write class Proc alias :eql? :== def hash inspect.sub(/^(#)$/){''}.to_i(16) end end /Christoph