Skip to content

Commit f98bbb7

Browse files
[DOC] Doc for Rational#<=>
1 parent 5272f2b commit f98bbb7

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

rational.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,20 +1077,30 @@ rb_rational_pow(VALUE self, VALUE other)
10771077

10781078
/*
10791079
* call-seq:
1080-
* rational <=> numeric -> -1, 0, +1, or nil
1080+
* self <=> other -> -1, 0, 1, or nil
10811081
*
1082-
* Returns -1, 0, or +1 depending on whether +rational+ is
1083-
* less than, equal to, or greater than +numeric+.
1082+
* Compares +self+ and +other+.
10841083
*
1085-
* +nil+ is returned if the two values are incomparable.
1084+
* Returns:
10861085
*
1087-
* Rational(2, 3) <=> Rational(2, 3) #=> 0
1088-
* Rational(5) <=> 5 #=> 0
1089-
* Rational(2, 3) <=> Rational(1, 3) #=> 1
1090-
* Rational(1, 3) <=> 1 #=> -1
1091-
* Rational(1, 3) <=> 0.3 #=> 1
1086+
* - +-1+, if +self+ is less than +other+.
1087+
* - +0+, if the two values are the same.
1088+
* - +1+, if +self+ is greater than +other+.
1089+
* - +nil+, if the two values are incomparable.
1090+
*
1091+
* Examples:
1092+
*
1093+
* Rational(2, 3) <=> Rational(4, 3) # => -1
1094+
* Rational(2, 1) <=> Rational(2, 1) # => 0
1095+
* Rational(2, 1) <=> 2 # => 0
1096+
* Rational(2, 1) <=> 2.0 # => 0
1097+
* Rational(2, 1) <=> Complex(2, 0) # => 0
1098+
* Rational(4, 3) <=> Rational(2, 3) # => 1
1099+
* Rational(4, 3) <=> :foo # => nil
1100+
*
1101+
* \Class \Rational includes module Comparable,
1102+
* each of whose methods uses Rational#<=> for comparison.
10921103
*
1093-
* Rational(1, 3) <=> "0.3" #=> nil
10941104
*/
10951105
VALUE
10961106
rb_rational_cmp(VALUE self, VALUE other)

0 commit comments

Comments
 (0)