New to Ruby - While loop issues in IRB

前端 未结 3 810
失恋的感觉
失恋的感觉 2020-12-20 06:51

So a few days ago I decided I would try and learn Ruby and it\'s actually been going pretty well. I\'ve been mostly fiddling around in IRB until I can find a non-trivial pr

3条回答
  •  余生分开走
    2020-12-20 07:31

    Ruby doesn't have C-style increment (++) or decrement (--) operators. You want this:

    i = 0
    while(i < 1000)
      i = i + 1 # Or i += 1
    end
    

提交回复
热议问题