「Ruby入門」whileを利用するサンプル
サンプル:
#!/usr/bin/ruby
# -*- coding: UTF-8 -*-
$i = 0
$num = 5
while $i < $num do
puts(“loop test i = #$i" )
$i +=1
end
結果
loop test i = 0
loop test i = 1
loop test i = 2
loop test i = 3
loop test i = 4
Coding Changes the World
サンプル:
#!/usr/bin/ruby
# -*- coding: UTF-8 -*-
$i = 0
$num = 5
while $i < $num do
puts(“loop test i = #$i" )
$i +=1
end
結果
loop test i = 0
loop test i = 1
loop test i = 2
loop test i = 3
loop test i = 4