パンくず
Ruby Cookbook
Array#Join
概要
Array#join
Array#Join
Array#joinメソッドに文字列を指定することで、
指定文字列を間に挟んで、配列内の文字列連結を行います。
サンプル
csv_columns = %w[one two three] puts csv_columns.join(",") # =>each文の場合,最後にchopする必要がある out = "" csv_columns.each {|column|out << "#{column},"} puts out puts out.chop
出力
one,two,three one,two,three, one,two,three