Golang Continue 语句

1 Apr 2025 | 2 分钟阅读

continue 用于跳过循环的剩余部分,然后在检查条件后继续循环的下一次迭代。

语法:-

或者我们可以这样做

Go Continue 语句示例

输出

value of a: 1
value of a: 2
value of a: 3
value of a: 4
value of a: 6
value of a: 7
value of a: 8
value of a: 9

Continue 也可以应用于内部循环

Go Continue 语句与内部循环示例

输出

value of a and b is 1 1
value of a and b is 1 2
value of a and b is 1 3
value of a and b is 2 1
value of a and b is 2 3
 
下一主题Golang-comments