[英]How to removal double quotes, commas, and brackets in the string array with Ruby and Rails?
我有一個字符串數組,如下所示:
array = ["A", "B", "C", "D"]
我正在使用respond_to do |format|
解析它.text
文件。
我的代碼:
respond_to do |format|
format.text { render text: array }
end
現在我想在這里做的是刪除所有的雙引號、逗號以及數組括號[]
並且每個值將在文本文件中用換行符分隔。
所以我希望在打開文本文件時我的結果是這樣的:
A
B
C
D
我如何實現這一目標?
你試過簡單嗎
respond_to do |format|
format.text { render text: array.join("\n") }
end
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.