ruby-changes:13669
From: matz <ko1@a...>
Date: Sun, 25 Oct 2009 01:48:20 +0900 (JST)
Subject: [ruby-changes:13669] Ruby:r25453 (trunk): * object.c (rb_obj_cmp): defines Object#<=>.
matz 2009-10-25 01:48:05 +0900 (Sun, 25 Oct 2009) New Revision: 25453 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25453 Log: * object.c (rb_obj_cmp): defines Object#<=>. [ruby-core:24063] Modified files: trunk/ChangeLog trunk/lib/delegate.rb trunk/object.c Index: ChangeLog =================================================================== --- ChangeLog (revision 25452) +++ ChangeLog (revision 25453) @@ -1,3 +1,7 @@ +Sat Oct 24 13:38:45 2009 Yukihiro Matsumoto <matz@r...> + + * object.c (rb_obj_cmp): defines Object#<=>. [ruby-core:24063] + Sat Oct 24 00:36:47 2009 Tanaka Akira <akr@f...> * io.c (io_cntl): update max file descriptor by the result of Index: object.c =================================================================== --- object.c (revision 25452) +++ object.c (revision 25453) @@ -1119,6 +1119,15 @@ } +/* :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 @@ 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); Index: lib/delegate.rb =================================================================== --- lib/delegate.rb (revision 25452) +++ lib/delegate.rb (revision 25453) @@ -115,7 +115,7 @@ # implementation, see SimpleDelegator. # class Delegator - [:to_s,:inspect,:=~,:!~,:===].each do |m| + [:to_s,:inspect,:=~,:!~,:===,:<=>].each do |m| undef_method m end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/