ruby-changes:67364
From: Nobuyoshi <ko1@a...>
Date: Mon, 30 Aug 2021 13:37:38 +0900 (JST)
Subject: [ruby-changes:67364] 465bd972ec (master): [DOC] Move rdoc of Integer#abs to numeric.rb [ci skip]
https://git.ruby-lang.org/ruby.git/commit/?id=465bd972ec From 465bd972ec2149be000dad9125bb8f4ab6762699 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 30 Aug 2021 13:20:03 +0900 Subject: [DOC] Move rdoc of Integer#abs to numeric.rb [ci skip] --- numeric.c | 16 ---------------- numeric.rb | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/numeric.c b/numeric.c index 755051d..bdf6b26 100644 --- a/numeric.c +++ b/numeric.c @@ -4670,22 +4670,6 @@ int_to_f(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L4670 return DBL2NUM(val); } -/* - * Document-method: Integer#abs - * Document-method: Integer#magnitude - * 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. - */ - static VALUE fix_abs(VALUE fix) { diff --git a/numeric.rb b/numeric.rb index c892cbe..1f86ba2 100644 --- a/numeric.rb +++ b/numeric.rb @@ -70,6 +70,17 @@ class Integer https://github.com/ruby/ruby/blob/trunk/numeric.rb#L70 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 https://github.com/ruby/ruby/blob/trunk/numeric.rb#L149 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/