Seems like it joins the array recursively. Source:

https://github.com/ruby/ruby/blob/trunk/array.c#L1979