Skip to content

Instantly share code, notes, and snippets.

@edj979
Created November 11, 2015 00:20
Show Gist options
  • Save edj979/7a7d088e2b6e80e8f55c to your computer and use it in GitHub Desktop.
Save edj979/7a7d088e2b6e80e8f55c to your computer and use it in GitHub Desktop.
def add(*numbers)
numbers.inject(0) { |sum, number| sum + number }
end
def add_with_message(message, *numbers)
"#{message} : #{add(*numbers)}"
end
puts add_with_message("The Sum is", 1, 2,32 ,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment