いつもいつも書き方を忘れるので、メモ書き
Hashから値だけを取り出す
Hash#values
を使う
sample.rb
profile = {"name" => "TomoProg", "blood" => "AB"}
profile.values # ["TomoProg", "AB"]
配列の要素をとある文字で区切りたい
Array#join
を使う
sample.rb
profile = ["TomoProg", "AB"]
profile.join # "TomoProgAB"
profile.join(',') # "TomoProg,AB"
文字列をとある文字で区切りたい
String#split
を使う
sample.rb
profile = "TomoProg,AB"
profile.split(',') # ["TomoProg", "AB"]
数値をカンマ区切りにしたい
to_s(:delimited)
を使う
sample.rb
num = 123456789
num.to_s(:delimited) # "123,456,789"