Skip to content

Instantly share code, notes, and snippets.

@ph3nx
Created January 19, 2014 16:42
Show Gist options
  • Save ph3nx/8507343 to your computer and use it in GitHub Desktop.
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.
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