times,upto,downto,each,step示例 博客分类: ruby Java
程序员文章站
2024-03-16 10:01:58
...
#times,upto,downto,each,step示例 3.times { print "Hi!" } #Hi!Hi!Hi! puts "\n" 1.upto(9) {|i| print i if i<7 }#123456 puts "\n" 9.downto(1){|i| print i if i<7 } #654321 puts "\n" (1..9).each {|i| print i if i<7} #123456 puts "\n" 0.step(11,2) {|i| print i } #0369