mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-27 21:58:57 +01:00
11 lines
170 B
Ruby
11 lines
170 B
Ruby
|
# 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
|