From cfd41cbf0338a28638ed54edb0de13539b159dfb Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Mon, 15 Dec 2025 21:28:41 +0000 Subject: [PATCH] [DOC] Harmonize #-@ methods --- complex.c | 4 ++-- numeric.c | 2 +- numeric.rb | 17 +++++++++++++---- rational.c | 8 ++++++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/complex.c b/complex.c index 2a92f4c702..eab6bde85a 100644 --- a/complex.c +++ b/complex.c @@ -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) diff --git a/numeric.c b/numeric.c index 5f2f4ea797..4e105baa81 100644 --- a/numeric.c +++ b/numeric.c @@ -576,7 +576,7 @@ num_imaginary(VALUE num) * call-seq: * -self -> numeric * - * Unary Minus---Returns the receiver, negated. + * Returns +self+, negated. */ static VALUE diff --git a/numeric.rb b/numeric.rb index 552a3dd687..306561943d 100644 --- a/numeric.rb +++ b/numeric.rb @@ -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 diff --git a/rational.c b/rational.c index f03a98a9ee..05dc3540c0 100644 --- a/rational.c +++ b/rational.c @@ -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)