diff options
author | zzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-23 02:11:53 +0000 |
---|---|---|
committer | zzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-23 02:11:53 +0000 |
commit | c135883d37d061dd52e15ea7d2c4d38361cf04fb (patch) | |
tree | 20d39f8b5dd801baa82cd647db116bc5b817fd6b | |
parent | 3331d6774f355e261644d7042cdeee0f03db3bc8 (diff) | |
download | ruby-c135883d37d061dd52e15ea7d2c4d38361cf04fb.tar.gz |
* object.c (rb_obj_comp): Documenting Object#<=> return values
Patch by Stefan Rusterholz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | object.c | 11 |
2 files changed, 16 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sat Feb 23 10:17:00 2013 Zachary Scott <zachary@zacharyscott.net> + + * object.c (rb_obj_comp): Documenting Object#<=> return values + Patch by Stefan Rusterholz + Sat Feb 23 09:48:41 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> * dir.c (file_s_fnmatch, fnmatch_brace): encoding-incompatible pattern @@ -1320,6 +1320,17 @@ rb_obj_not_match(VALUE obj1, VALUE obj2) * obj <=> other -> 0 or nil * * Returns 0 if obj === other, otherwise nil. + * + * The <=> is used by various methods to compare objects, for example + * Enumerable#sort, Enumerable#max etc. + * + * Your implementation of <=> should return one of the following values: -1, 0, + * 1 or nil. -1 means self is smaller than other. 0 means self is equal to other. + * 1 means self is bigger than other. Nil means the two values could not be + * compared. + * + * When you defined <=>, you can include Comparable to gain the methods <=, <, + * ==, >=, > and between?. */ static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2) |