当前位置:网站首页>Advanced usage of go language for loop break and continue
Advanced usage of go language for loop break and continue
2022-06-30 14:07:00 【Zhen Jie.】
break:
break Statements can end for、switch and select Code block for .break Statements can also be tagged after statements **( In the following code BreakTag、BreakTag2)**, Indicates to exit the code block corresponding to a tag , Label requirements must be defined in the corresponding for、switch and select On the code block of .
BreakTag:
for i := 0; i < 5; i++ {
BreakTag2:
for j := 0; j < 4; j++ {
fmt.Println(i, j)
switch i {
case 1:
break BreakTag
case 3:
break BreakTag2
}
}
}
Print the results :
0 0
0 1
0 2
0 3
1 0
Print result interpretation ( Fine products ! Fine products ! Fine products !):
0 0
0 1
0 2
0 3
# The lack of 0 4 because break Out of the way BreakTag2 loop
1 0
# The lack of 1 1 1 2 ..... because break Out of the way BreakTag loop
continue( Usage and break The same ):
continue Statement can end the current loop , Start the next iteration of the loop , Only in for Use in cycle . stay continue When you add a label after a statement , Represents the loop corresponding to the start tag
ContinueTag:
for i := 0; i < 5; i++ {
ContinueTag2:
for j := 0; j < 4; j++ {
fmt.Println(i, j)
switch i {
case 1:
break ContinueTag
case 3:
break ContinueTag2
}
}
}
Print the results :
0 0
0 1
0 2
0 3
1 0
边栏推荐
- numpy 创建空数组 data = np.empty(shape=[1, 64,64,3])
- 可觀測,才可靠:雲上自動化運維CloudOps系列沙龍 第一彈
- Impersonate server and client using message queuing
- MFQE 2.0: A New Approach for Multi-FrameQuality Enhancement on Compressed Video
- 【刷题篇】爱吃香蕉的珂珂
- Lucky hash quiz system development (source code deployment) fun investment hash game play development (case requirements)
- "As a service", the inevitable choice of enterprise digital transformation
- [the path of system analyst] Chapter 5 Software Engineering (Agile Development)
- 随着产业互联网的发展,有关互联网的落地和应用也就变得宽阔了起来
- 【刷题篇】供暖器
猜你喜欢

【科学文献计量】外文文献及中文文献关键词的挖掘与可视化

On the simplification and acceleration of join operation

Wuenda 2022 machine learning special course evaluation is coming!

Google Earth engine (GEE) - ghsl: global human settlements layer, built grid 1975-1990-2000-2015 (p2016) data set

Assertions of regular series
![【科研数据处理】[基础]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)](/img/70/8bf226964118efb324ca4d339df654.png)
【科研数据处理】[基础]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)

【Redis 系列】redis 学习十六,redis 字典(map) 及其核心编码结构

华为帐号多端协同,打造美好互联生活

香港回归20余年,图扑数字孪生港珠澳大桥,超震撼

Defi "where does the money come from"? A problem that most people don't understand
随机推荐
正则系列之断言Assertions
mysql拒绝访问、管理员身份打开的
This editor will open source soon!
Unity animator parameter
The programming competition is coming! B station surrounding, senior members and other good gifts to you!
单元测试效率优化:为什么要对程序进行测试?测试有什么好处?
How can c write an SQL parser
[the path of system analyst] Chapter V software engineering (software process improvement)
Why can't the database table be written into data
【科学文献计量】外文文献及中文文献关键词的挖掘与可视化
Multi terminal collaboration of Huawei accounts to create a better internet life
Dart extended feature
Write, append, read, and copy of golang files: examples of using bufio packages
Optimization of unit test efficiency: why test programs? What are the benefits of testing?
损失函数:DIOU loss手写实现
【科研数据处理】[基础]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)
On the simplification and acceleration of join operation
Waving flags and shouting for basic language
(8) JMeter component detailed once only controller
第四批入围企业公示——年度TOP100智能网联供应商评选