Joining arrays, the ruby way
Like PHP’s join function but in more elegant ruby way. Let’s see how can you do it:
[1, 2, 3, 4, 5].join(',')
Or:
[1, 2, 3, 4, 5] * ','
Yes, the multiply operator does the job as well.
Or:
(1..5).to_a * ','
Each time the same result:
=> "1,2,3,4,5"
I never play videogames, but with programming languages in My free time, hope You enjoy reading.
Comments