mirror of
https://github.com/TheAlgorithms/Ruby
synced 2025-01-13 08:01:03 +01:00
renaming
This commit is contained in:
parent
ae40765c38
commit
0df659abae
1 changed files with 6 additions and 6 deletions
12
maths/add.rb
12
maths/add.rb
|
@ -2,7 +2,7 @@
|
||||||
# Addition or sum of numbers means adding each and every element of the inputs
|
# Addition or sum of numbers means adding each and every element of the inputs
|
||||||
# Sum or addition of 1 and 3 is 1 + 3 = 4
|
# Sum or addition of 1 and 3 is 1 + 3 = 4
|
||||||
|
|
||||||
def self_add(*array)
|
def add(*array)
|
||||||
sum = 0
|
sum = 0
|
||||||
array.each { |a| sum+=a }
|
array.each { |a| sum+=a }
|
||||||
puts "The sum of following elements #{array} is #{sum}"
|
puts "The sum of following elements #{array} is #{sum}"
|
||||||
|
@ -11,10 +11,10 @@ def self_add(*array)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Valid inputs
|
# Valid inputs
|
||||||
self_add(1)
|
add(1)
|
||||||
self_add(2, 5, -4)
|
add(2, 5, -4)
|
||||||
self_add(25, 45)
|
add(25, 45)
|
||||||
|
|
||||||
# Invalid inputs
|
# Invalid inputs
|
||||||
self_add("1", 2, 3)
|
add("1", 2, 3)
|
||||||
self_add("a", 1)
|
add("a", 1)
|
||||||
|
|
Loading…
Reference in a new issue