Different ways to join array elements

Different ways to join array elements

Share it now. It takes only a few seconds! 😉


Different ways to join array elements

%w(www rubycademy com).join(?.) # => "www.rubycademy.com"
%w(www rubycademy com) * ?.     # => "www.rubycademy.com"

These methods also flatten subarrays

[ 1, 2, 3, [4, [5]] ].join(?-) # => "1-2-3-4-5"
[ 1, 2, 3, [4, [5]] ] * ?-     # => "1-2-3-4-5"

We're also available on