Created
January 19, 2014 16:42
-
-
Save ph3nx/8507343 to your computer and use it in GitHub Desktop.
Example Ruby method with a splat argument. Splat arguments are preceded by a *. You use them when you don't know how many arguments there will be.
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 greet message, *people | |
people.each { |p| puts "#{message}, #{p}!" } | |
end | |
greet "Hello", "Tony", "Ann", "BadMan" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment