`
weiweichen1985
  • 浏览: 137685 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

times,upto,downto,each,step示例

    博客分类:
  • ruby
阅读更多
#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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics