Skip to content

Instantly share code, notes, and snippets.

@dogweather
Created December 10, 2013 23:00
Show Gist options
  • Select an option

  • Save dogweather/7901986 to your computer and use it in GitHub Desktop.

Select an option

Save dogweather/7901986 to your computer and use it in GitHub Desktop.
Define a method with a variable length argument list
func(1, 2, 3, 4, 5)
# The argument with the "splat operator" denotes
# a variable number of arguments which will be
# placed into an array.
def func(arg1, arg2, *other_args)
p arg1.inspect # => 1
p arg2.inspect # => 2
p other_args.inspect # => [3, 4, 5]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment