Equivalent of “continue” in Ruby

后端 未结 7 1410
离开以前
离开以前 2020-12-07 07:13

In C and many other languages, there is a continue keyword that, when used inside of a loop, jumps to the next iteration of the loop. Is there any equivalent of

相关标签:
7条回答
  • 2020-12-07 08:04

    Inside for-loops and iterator methods like each and map the next keyword in ruby will have the effect of jumping to the next iteration of the loop (same as continue in C).

    However what it actually does is just to return from the current block. So you can use it with any method that takes a block - even if it has nothing to do with iteration.

    0 讨论(0)
提交回复
热议问题