summaryrefslogtreecommitdiff
path: root/numeric.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-30 13:20:03 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-30 13:33:52 +0900
commit465bd972ec2149be000dad9125bb8f4ab6762699 (patch)
tree72d9ecf9b59c43fd32f6698899b82181e16440cc /numeric.rb
parent66a4768f65423189e61d39a473a031a5eb0253ea (diff)
[DOC] Move rdoc of Integer#abs to numeric.rb [ci skip]
Diffstat (limited to 'numeric.rb')
-rw-r--r--numeric.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/numeric.rb b/numeric.rb
index c892cbe6ef..1f86ba2e1b 100644
--- a/numeric.rb
+++ b/numeric.rb
@@ -70,6 +70,17 @@ class Integer
Primitive.cexpr! 'rb_int_comp(self)'
end
+ # call-seq:
+ # int.abs -> integer
+ # int.magnitude -> integer
+ #
+ # Returns the absolute value of +int+.
+ #
+ # (-12345).abs #=> 12345
+ # -12345.abs #=> 12345
+ # 12345.abs #=> 12345
+ #
+ # Integer#magnitude is an alias for Integer#abs.
def abs
Primitive.attr! 'inline'
Primitive.cexpr! 'rb_int_abs(self)'
@@ -138,10 +149,13 @@ class Integer
return true
end
+ alias magnitude abs
+=begin
def magnitude
Primitive.attr! 'inline'
Primitive.cexpr! 'rb_int_abs(self)'
end
+=end
# call-seq:
# int.odd? -> true or false