1
0
Fork 0
mirror of https://github.com/TheAlgorithms/Ruby synced 2025-01-20 10:26:17 +01:00
TheAlgorithms-Ruby/maths/abs.rb

11 lines
170 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# Calculates the absolute value of a number
class Abs
def self.call(number)
return -number if number.negative?
number
end
end