summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorzverok <zverok.offline@gmail.com>2022-12-21 21:51:08 +0200
committerVictor Shepelev <zverok.offline@gmail.com>2022-12-23 18:09:49 +0200
commit64cdf1936a3952fbd43083de55244dd1b701cce6 (patch)
tree5c721957b8464263def40afb359380fd0ad5231a /proc.c
parentb3d57fdd64d2e88499bf718e64522dfce9358c48 (diff)
downloadruby-64cdf1936a3952fbd43083de55244dd1b701cce6.tar.gz
Docs: Separate documentation for UnboundMethod#==
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/proc.c b/proc.c
index e4762db494..c31017128e 100644
--- a/proc.c
+++ b/proc.c
@@ -1842,6 +1842,22 @@ method_eq(VALUE method, VALUE other)
/*
* 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
*
* Returns a hash value corresponding to the method object.
@@ -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);