Skip to content

Instantly share code, notes, and snippets.

@bschaeffer
Created March 7, 2012 23:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bschaeffer/1997200 to your computer and use it in GitHub Desktop.
Save bschaeffer/1997200 to your computer and use it in GitHub Desktop.
Ruby *args examples
ids = [1,2,3]
def targs(*ids)
puts ids.length
puts ids.flatten.length
end
targs ids
#=> 1
#=> 3
targs *ids
#=> 3
#=> 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment