add output for add algo

This commit is contained in:
Vitor Oliveira 2021-04-14 16:40:39 -07:00 committed by GitHub
parent fbe6e9851d
commit 256f376574
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,11 +10,25 @@ def add(*array)
puts "Error: Please provide number only!"
end
#
# Valid inputs
add(1)
add(2, 5, -4)
add(25, 45)
#
puts add(1)
# The sum of following elements [1] is 1
puts add(2, 5, -4)
# The sum of following elements [2, 5, -4] is 3
puts add(25, 45)
# The sum of following elements [25, 45] is 70
#
# Invalid inputs
add("1", 2, 3)
add("a", 1)
#
puts add("1", 2, 3)
# Error: Please provide number only!
puts add("a", 1)
# Error: Please provide number only!