summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-24 16:48:05 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-24 16:48:05 +0000
commit51f033f85354cdd22f7c39b77bf6c39afaec09f9 (patch)
treec2db25ebc5acab448c3a45763e418ae3e8650e98 /object.c
parent66ed25f6336fddb036fb2408e4e4c4316b427330 (diff)
* object.c (rb_obj_cmp): defines Object#<=>. [ruby-core:24063]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/object.c b/object.c
index 6e69343732..9f7537f12b 100644
--- a/object.c
+++ b/object.c
@@ -1119,6 +1119,15 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
}
+/* :nodoc: */
+static VALUE
+rb_obj_cmp(VALUE obj1, VALUE obj2)
+{
+ if (obj1 == obj2 || rb_obj_equal(obj1, obj2))
+ return INT2FIX(0);
+ return Qnil;
+}
+
/***********************************************************************
*
* Document-class: Module
@@ -2555,6 +2564,7 @@ Init_Object(void)
rb_define_method(rb_mKernel, "!~", rb_obj_not_match, 1);
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
rb_define_method(rb_mKernel, "hash", rb_obj_hash, 0);
+ rb_define_method(rb_mKernel, "<=>", rb_obj_cmp, 1);
rb_define_method(rb_mKernel, "class", rb_obj_class, 0);
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);