| Start |
|---|
| Coercing arrays into parameter list Suppose you had an array: And a method that takes two arguments: You might think you could just pass the array: Since the array is just one argument, not two, so Ruby throws an exception. You could pull out each element individually: Or you can use the splat operator to save yourself some effort: |
| Variable number of arguments The splat operator removes individual elements of an array and makes them into a list. This is most commonly used to create a method that accepts a variable number of arguments: Notice that an array only counts as one item on the list, so you will need to us the splat operator on the calling side too if you have an array you want to pass: |
Read Article
https://develop.horje.com/learn/1434/reference