package main
//支持跳转到指定循环
func main() {
OutLoop:
for i:=0;i<2 ;i++ {
for j:=0;j<5 ;j++ {
switch j {
case 2:
println(i,j)
break OutLoop
case 3:
println(i,j)
break OutLoop
}
}
}
}
本文展示了一个使用Go语言编写的程序示例,该程序利用嵌套循环和switch语句来演示如何在特定条件下跳出外层循环。通过标签OutLoop和break OutLoop实现了对循环流程的精确控制。
package main
//支持跳转到指定循环
func main() {
OutLoop:
for i:=0;i<2 ;i++ {
for j:=0;j<5 ;j++ {
switch j {
case 2:
println(i,j)
break OutLoop
case 3:
println(i,j)
break OutLoop
}
}
}
}

被折叠的 条评论
为什么被折叠?