0003 Splat_operator

The splat operator is a handy way of manipulating arrays and arguments.

It is possible to deconstruct/decompose an array during assignment.

0003-splat_operator_1.png

This also applies when creating an array.

0003-splat_operator_2.png

When defining a method, the splat operator merges the targeted arguments into a single array.

0003-splat_operator_3.png

When calling a method, the splat operator turns an array into an argument list.

0003-splat_operator_4.png

Links to Ruby documentation for the splat operator: assignment, method arguments*.

*Note that the documentation is not up to date: The behavior about keyword arguments is effectively removed and there is no warning if the splat operator comes first when calling a method without parentheses.