「Ruby」for文で配列の要素から値を取り出すサンプル
書式
for 変数名 in 配列名
some code
end
使用例
#!/usr/bin/ruby # -*- coding: UTF-8 -*- cft = ["study","skill","arkgame",".","com"] for k in cft puts "123 " + k end
実行結果
>ruby test.rb
123 study
123 skill
123 arkgame
123 .
123 com