Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Numeric#abs
abs → numeric
numeric.c
View on GitHub ↗
static VALUE
num_abs(VALUE num)
{
if (rb_num_negative_int_p(num)) {
return num_funcall0(num, idUMinus);
}
return num;
}
Returns the absolute value of self.
Example
12.abs #=> 12 (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56