The Splat(*) Operator

2012-05-18

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.

I’m currently working on fyra.sh, a CLI-first static site deployment tool where you push your site and it’s served globally through a built-in CDN, without the overhead of heavy platforms.