How to make n-D array into a string in ruby?

I’ve a n-D array, I want to make it into a single string (or array), like the example i’m giving below. I’ve tried using the flatten and concatenate but I’m not getting the desired result.
For example,

 [[:C], [:C, [[:C]]], [:C], [:C], [:C], [:C, [[:C]]], [:C, [[:C],
 [:C]]], [:C], [:C]]

In the above array the output should be CC(C)CCCC(C)C(CC)CC.
I want it with brackets so that it can be easily identified. If I m using flatten or concat. I’m getting CCCCCCCCCCCCC. I want it with brackets.


Source: ruby

Leave a Reply