Every programmer has used the method called ‘join’. We have an array, we want to connect items.

[1,2,3].join # => "123"

Super simple. But what if you set the default separator?

$, = "_"
[1,2,3].join # => "1_2_3"

Wooops :) Do you think that your project is not affected?

Think again and try use .join('') instead of .join.

IMPORTANT

$, = "_"
[1,2,3].join(nil) # => 1_2_3

Links



blog comments powered by Disqus

Published

18 July 2012

Tags