Array.join for nested arrays

Doing

arr = [1, [2, [3, 4], 5], 6]
arr.join(’,’)

in Ruby 1.8.6 produces the following string:

1,2,3,4,5,6

Looking at the docs (e.g. http://www.noobkit.com/ruby-array-join),
Array.join should work as following:

“Returns a string created by converting each element of the array to a
string, separated by sep.”

Doing the following:

arr.each do |e|

However, this is not what I expected - I would have expected:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs