Skip to content

Commit fd05c11

Browse files
authored
Merge pull request #2263 from pocke/Complex#<=>
Add Complex#<=> since Ruby 2.7
2 parents dbbccf4 + adbb902 commit fd05c11

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

refm/api/src/_builtin/Complex

+21
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,27 @@ Complex(1, 0) == Complex(1) # => true
107107
Complex(1, 0) == 1 # => true
108108
#@end
109109

110+
#@since 2.7.0
111+
--- <=>(other) -> -1 | 0 | 1 | nil
112+
113+
self の虚部がゼロで other が実数の場合、
114+
self の実部の <=> メソッドで other と比較した結果を返します。
115+
other が Complex で虚部がゼロの場合も同様です。
116+
117+
その他の場合は nil を返します。
118+
119+
@param other 自身と比較する数値
120+
121+
#@samplecode 例
122+
Complex(2, 3) <=> Complex(2, 3) #=> nil
123+
Complex(2, 3) <=> 1 #=> nil
124+
Complex(2) <=> 1 #=> 1
125+
Complex(2) <=> 2 #=> 0
126+
Complex(2) <=> 3 #=> -1
127+
#@end
128+
129+
#@end
130+
110131
--- abs -> Numeric
111132
--- magnitude -> Numeric
112133

0 commit comments

Comments
 (0)