# Array.join for nested arrays

**URL:** <https://www.ruby-forum.com/t/array-join-for-nested-arrays/108065>\
**Category:** Ruby\
**Created:** [June 28, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/array-join-for-nested-arrays/108065 "2007-06-28T20:42:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 28, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/array-join-for-nested-arrays/108065/1 "2007-06-28T20:42:22Z")

</div>

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](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:
