From 64cdf1936a3952fbd43083de55244dd1b701cce6 Mon Sep 17 00:00:00 2001 From: zverok Date: Wed, 21 Dec 2022 21:51:08 +0200 Subject: Docs: Separate documentation for UnboundMethod#== --- proc.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index e4762db494..c31017128e 100644 --- a/proc.c +++ b/proc.c @@ -1840,6 +1840,22 @@ method_eq(VALUE method, VALUE other) return Qtrue; } +/* + * call-seq: + * meth.eql?(other_meth) -> true or false + * meth == other_meth -> true or false + * + * Two unbound method objects are equal if they refer to the same + * method definition. + * + * Array.instance_method(:each_slice) == Enumerable.instance_method(:each_slice) + * #=> true + * + * Array.instance_method(:sum) == Enumerable.instance_method(:sum) + * #=> false, Array redefines the method for efficiency + */ +#define unbound_method_eq method_eq + /* * call-seq: * meth.hash -> integer @@ -4334,8 +4350,8 @@ Init_Proc(void) rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject); rb_undef_alloc_func(rb_cUnboundMethod); rb_undef_method(CLASS_OF(rb_cUnboundMethod), "new"); - rb_define_method(rb_cUnboundMethod, "==", method_eq, 1); - rb_define_method(rb_cUnboundMethod, "eql?", method_eq, 1); + rb_define_method(rb_cUnboundMethod, "==", unbound_method_eq, 1); + rb_define_method(rb_cUnboundMethod, "eql?", unbound_method_eq, 1); rb_define_method(rb_cUnboundMethod, "hash", method_hash, 0); rb_define_method(rb_cUnboundMethod, "clone", method_clone, 0); rb_define_method(rb_cUnboundMethod, "arity", method_arity_m, 0); -- cgit v1.2.1