Created
June 17, 2017 06:48
-
-
Save Y-Fujikawa/633a7e408b04e4ea3758be19b664394f to your computer and use it in GitHub Desktop.
可変長引数のサンプルソース
This file contains 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
# 引数を元にメッセージを表示する | |
def display_messages(name, *messages) | |
messages.each do |message| | |
p "#{name} : #{message}" | |
end | |
end | |
# 実行 | |
display_messages 'John', 'Hello', 'Goodbye', 'Thank you' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment