Created
March 4, 2017 20:25
-
-
Save KennethanCeyer/7d02f92ba85c16533668bfe6cdd6e4a5 to your computer and use it in GitHub Desktop.
Ruby module definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './math' | |
puts Math.sum(1, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Math | |
def Math.sum(*args) | |
total = 0 | |
args.each do |item| | |
total += item | |
end | |
return total | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment