From: Edwin Fine Date: 2007-02-13T15:24:39+09:00 Subject: Re: What is Proc#== Here's the C code for proc_eq (in eval.c). It seems that the procs have to either be the same object, or failing that have the same type (T_DATA), class, body, variables, scope, in-block local variables (dyna_vars), and flags. static VALUE proc_eq(self, other) VALUE self, other; { struct BLOCK *data, *data2; if (self == other) return Qtrue; if (TYPE(other) != T_DATA) return Qfalse; if (RDATA(other)->dmark != (RUBY_DATA_FUNC)blk_mark) return Qfalse; if (CLASS_OF(self) != CLASS_OF(other)) return Qfalse; Data_Get_Struct(self, struct BLOCK, data); Data_Get_Struct(other, struct BLOCK, data2); if (data->body != data2->body) return Qfalse; if (data->var != data2->var) return Qfalse; if (data->scope != data2->scope) return Qfalse; if (data->dyna_vars != data2->dyna_vars) return Qfalse; if (data->flags != data2->flags) return Qfalse; return Qtrue; } The only way so far that I have been able to create two equal procs that have different object IDs is to clone or dup them. I am sure there must be another way using some metaprogramming, but I am not experienced enough in Ruby to find it easily (or maybe ever:) irb(main):001:0> a = lambda { 4 } => # irb(main):002:0> b = a.clone => # irb(main):003:0> a.object_id => 23944093823940 irb(main):004:0> b.object_id => 23944093815980 irb(main):005:0> a == b => true -- Posted via http://www.ruby-forum.com/.