The Splat(*) Operator

Learnt something new today.

When trying to split a multi-dimensional array, one could use the *(splat) operator.

a = [[1,2],[3,4]]
b = [[5,6],[7,8]]

In order to include b into a without breaking the array, you could do the following:

a = [[1,2],[3,4], *b]
# a = [[1,2],[3,4],[5,6],[7,8]]

And that’s the magic of *splat.