「Ruby」joinを使って文字列を結合する
書式
対象文字列.join(“区切り文字")
使用例
#!/usr/bin/ruby p "区切り文字:スペース" p ["study","skill","become","smart"].join(" ") p "区切文字:," p ["study","skill","become","smart"].join(",") p "区切り文字:特手文字" p ["study","skill",].join("tokyo") p "区切文字列:-" p ["study","skill","smart"].join("-") p "区切文字列:+" p ["study","skill","smart"].join("+")
結果
"区切り文字:スペース" "study skill become smart" "区切文字:," "study,skill,become,smart" "区切り文字:特手文字" "studytokyoskill" "区切文字列:-" "study-skill-smart" "区切文字列:+" "study+skill+smart"