当前位置:网站首页>Golang Break, Continue out of multi-layer cycle
Golang Break, Continue out of multi-layer cycle
2022-08-07 04:09:00 【@aircraft carrier】
Break
Thebreak statement can end for, switch, and select blocks of code.Break just jumps out of a for loop when no label is used.The break statement can also add a label after the statement to indicate exiting the code block corresponding to a label. The label must be defined on the corresponding for, switch and select code blocks.
func main() {OuterLoop:for i := 0; i < 2; i++ {for j := 0; j < 5; j++ {switch j {case 2:fmt.Println(i, j)break OuterLoopcase 3:fmt.Println(i, j)break OuterLoop}}}}continue
Thecontinue statement can end the current loop and start the next loop iteration process. It can only be used in for loops.When adding a label after the continue statement, it means to start the loop corresponding to the label.For example:
func main() {OuterLoop:for i := 0; i < 2; i++ {for j := 0; j < 5; j++ {switch j {case 2:fmt.Println(i, j)continue OuterLoop}}}}边栏推荐
猜你喜欢

WeChat applet's campus job search and recruitment system uniapp with source code

typescript79-配置文件tsconfig.json文件

Collections and Iterators

typescript85-class组件类型

【LeetCode每日一题】——153.寻找旋转排序数组中的最小值

Reading Notes - RetinaFace: Single-stage Dense Face Localisation in the Wild

SaaS服务平台软件是什么?

Automatic water quality monitoring and video monitoring to consolidate and improve the level of drinking water safety

2022 Niu Ke Duo School Six M-Z-Game on grid (dynamic programming)

typescript80-使用配置文件编译文件
随机推荐
2333. Minimum difference sum of squares - sorting and binary search
golang server proxy
M write log to text
2022-08-06:给定一个数组arr,长度为N,arr中所有的值都在1~K范围上, 你可以删除数字,目的是让arr的最长递增子序列长度小于K。 返回至少删除几个数字能达到目的。 N <= 10^4
工业5g路由器厂家
5G/4G water resource remote control terminal
“go1.15.3“ does not match go tool version “go1.13.8“
【TypeScript笔记】02 - TS高级类型
【RF】射频集成电路与系统设计
navicat linked server mysql
集合与迭代器
Product system module of advertising e-commerce system development function
基于7.6ElstaicSearch 语法的基本用法
npm install遇到Unexpected end of JSON input while parsing near ‘...onnect“:“^2.0.0“,“gru‘问题解决
Automatic water quality monitoring and video monitoring to consolidate and improve the level of drinking water safety
Scrollbar for TreeView in wpf
SaaS服务平台软件是什么?
建筑工地无线视频监控 工业级无线路由器应用
Wireless Video Surveillance of Construction Site Industrial Grade Wireless Router Application
406. According to height reconstruction queue - sort + dynamic programming