From: Tomasz Wegrzanowski Date: 2006-09-05T10:20:21+09:00 Subject: Re: Kernel.=== in case statements, even though I never calle On 9/5/06, Jesse Silliman wrote: > Oh, I'm quite aware of that. Oh... its calling the objects inherited > Kernel.===, not calling Kernel::===. Ok, well, in that case, a good > question would be "Why is it so much slower in simple cases than == is, > even though for string they do the exact same thing?" Kernel#=== calls == method, not aliases it. So you have 2 method calls, and two dynamic dispatches instead of one: Kernel#===, then String#==. You can test this by alias_method'ing === to == in String class ;-) Relevant code: VALUE rb_equal(VALUE obj1, VALUE obj2) { VALUE result; if (obj1 == obj2) return Qtrue; result = rb_funcall(obj1, id_eq, 1, obj2); if (RTEST(result)) return Qtrue; return Qfalse; } -- Tomasz Wegrzanowski [ http://t-a-w.blogspot.com/ ]