除了无条件(loop)和有条件(while,until)之外,还可以循环一个值列表,对每个值都循环运行一次。ruby提供很多方式,其中一个关键字 for
ceshi=[1,2,3,4,5]
for c in ceshi
puts c+2
end
除了无条件(loop)和有条件(while,until)之外,还可以循环一个值列表,对每个值都循环运行一次。ruby提供很多方式,其中一个关键字 for
ceshi=[1,2,3,4,5]
for c in ceshi
puts c+2
end