「Ruby入門」for文を利用するサンプル

書式

for 変数名 in オブジェクト do
    some code
end

使用例

#!/usr/bin/ruby
# -*- coding: UTF-8 -*-

cft = ["study","in","arkgame",".","com"]
 
for k in cft do
      puts "TEST " + k+ " DATA" 
end

実行結果
>ruby test.rb
TEST study DATA
TEST in DATA
TEST arkgame DATA
TEST . DATA
TEST com DATA

Ruby

Posted by arkgame