summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurdetteLamar <burdettelamar@yahoo.com>2025-12-15 21:28:41 +0000
committerPeter Zhu <peter@peterzhu.ca>2025-12-15 17:28:35 -0500
commitcfd41cbf0338a28638ed54edb0de13539b159dfb (patch)
tree8cbbc6e68d7ffe6b1e2037e1afae3c3e8671dea7
parentacbf55f4e6658f94e49f28b4df21ab0c29683c4b (diff)
[DOC] Harmonize #-@ methods
-rw-r--r--complex.c4
-rw-r--r--numeric.c2
-rw-r--r--numeric.rb17
-rw-r--r--rational.c8
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)