摘要: 1、whilewhile a<10 puts a a=a+1end( puts a a=a+1) while a<102、untiluntil a>=10 puts a a=a+1end3、forfor i in 1..9 puts iend注意:尽量不要使用for循环,因为for循环会额外产生一个变量,如上面的i,for循环结束后i并不消失,很容易与循环外代码产生冲突。4、times3.times do |i| puts iend5、upto,downto1.upto(9) do |i| puts iend9.downto(1) do |i| puts iend6、step 阅读全文
posted @ 2011-06-13 12:06 承古韵 阅读(330) 评论(0) 推荐(0) 编辑