我正在将一些python代码转换为rebol,我只是遇到了一个"继续"指令.它会中断循环的处理,进入循环的下一次迭代.
我发现这个词非常优雅和可读.
我在那里遇到了一些答案:(法语),但没有什么真正"优雅":http: //pl.legoff.free.fr/dotclear/vf/index.php/post/2003/01/05/Equivalent-d -un-Continue-ou-Next-dans-une-bouc 由于这次会议大约有10年的历史,Rebol可能会有一些改进吗?
您可以使用例外在Rebol2中执行此操作:
continue: does [throw 'continue]
loop 2 [
catch [
print {"This'll print", {DocKimbel} said.}
continue
print {"This won't print", {DocKimbel} said.}
]
]
Run Code Online (Sandbox Code Playgroud)
如果你要在循环中处理自定义异常,你可以使用/ name细化,如catch/name [...]'继续避免捕获其他异常.甚至可以覆盖迭代器来为您透明地执行它,但代价是一些较慢的性能.
| 归档时间: |
|
| 查看次数: |
397 次 |
| 最近记录: |