I’ve had some people tell me that they didn’t know about the splat operator in Ruby (
*array) so here’s a quick example of how it’s used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
>> array = [:a, :b, :c] [  :a,  :b,  :c ] >> a, b, c = *array [  :a,  :b,  :c ] >> a :a >> b :b >> c :c
It splits the elements of the array into single items which are returned as a group (I think they are called parameters). So in second statement in the example above:
agets the first element of
bgets the second element of
cgets the third element of
This is commonly used to set a bunch of variables or when working with a method’s arguments (e.g. in a monkey patch).