[DOC] Harmonize #-@ methods

This commit is contained in:
BurdetteLamar 2025-12-15 21:28:41 +00:00 committed by Peter Zhu
parent acbf55f4e6
commit cfd41cbf03
Notes: git 2025-12-15 22:29:01 +00:00
4 changed files with 22 additions and 9 deletions

View File

@ -799,9 +799,9 @@ rb_complex_imag(VALUE self)
/*
* call-seq:
* -complex -> new_complex
* -self -> complex
*
* Returns the negation of +self+, which is the negation of each of its parts:
* Returns +self+, negated, which is the negation of each of its parts:
*
* -Complex.rect(1, 2) # => (-1-2i)
* -Complex.rect(-1, -2) # => (1+2i)

View File

@ -576,7 +576,7 @@ num_imaginary(VALUE num)
* call-seq:
* -self -> numeric
*
* Unary Minus---Returns the receiver, negated.
* Returns +self+, negated.
*/
static VALUE

View File

@ -93,9 +93,14 @@ end
class Integer
# call-seq:
# -int -> integer
# -self -> integer
#
# Returns +self+, negated:
#
# -1 # => -1
# -(-1) # => 1
# -0 # => 0
#
# Returns +self+, negated.
def -@
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_uminus(self)'
@ -373,9 +378,13 @@ class Float
alias magnitude abs
# call-seq:
# -float -> float
# -self -> float
#
# Returns +self+, negated.
# Returns +self+, negated:
#
# -3.14 # => -3.14
# -(-3.14) # => 3.14
# -0.0 # => -0.0
#
def -@
Primitive.attr! :leaf

View File

@ -609,9 +609,13 @@ nurat_denominator(VALUE self)
/*
* call-seq:
* -rat -> rational
* -self -> rational
*
* Returns +self+, negated:
*
* -(1/3r) # => (-1/3)
* -(-1/3r) # => (1/3)
*
* Negates +rat+.
*/
VALUE
rb_rational_uminus(VALUE self)