r/ruby • u/persei8 • Jul 18 '12
Default separator - .join ghetto
http://ruby-blog.pl/2012/07/18/default-separator---join-ghetto/
2
Upvotes
7
u/TheDeadSerious Jul 18 '12
Can we quit using the term Ghetto already, please? Vastly inappropriate. If you want to play the blame-game, use tarpit or something.
1
u/postmodern Jul 19 '12 edited Jul 19 '12
In Ruby 1.8 Array#join used to use $/ as the separator. This was changed to $, in Ruby 1.9. You shouldn't rely on the default value of the separator argument in Array#join for 1.8/1.9 compatibility.
Also, stop abusing the word Ghetto.
-2
u/SeattleTomy Jul 18 '12
Don't ever rely on the default separator. Your code will be more clear and less breakable if you document your intent in the code:
['a','b','c'].join(' ')
"This is a string".split(' ')
9
u/TaiGat Jul 18 '12
Whole post could be replaced with this link...