Array.join(“\n”) not the way to join with a newline?

后端 未结 7 1546
遥遥无期
遥遥无期 2020-12-29 01:44

I have an array..

[1,2,3,4]

and I want a string containing all the elements separated by a newline..

1

2

3

4
         


        
7条回答
  •  遥遥无期
    2020-12-29 02:35

    Just in case anyone searching for this functionality in ERB template then try this :

    (1..5).to_a.join("
    ").html_safe

提交回复
热议问题