Skip to content

Instantly share code, notes, and snippets.

@snuxoll
Created March 15, 2009 00:53
Show Gist options
  • Save snuxoll/79250 to your computer and use it in GitHub Desktop.
Save snuxoll/79250 to your computer and use it in GitHub Desktop.
# Adds the two arguments passed in to the method
def add(num1, num2)
num1 + num2
end
# We have an array that we want to pass in to add,
# with each item as a seperate argument
my_args = [1, 2]
# Prefixing a variable name with a * will attempt
# to break it into components and send each as a
# seperate argument
puts add(*my_args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment