当前位置:网站首页>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
边栏推荐
- [the path of system analyst] Chapter 5 Software Engineering (Agile Development)
- Read all the knowledge points about enterprise im in one article
- 嵌入式开发:5个可能不再被禁止的C特征
- 第四批入围企业公示——年度TOP100智能网联供应商评选
- 重磅:国产IDE发布,由阿里研发,完全开源!
- SQL attendance statistics monthly report
- 表格储存中sql查询的时候,查询结果增加主键报错,查询结果超过10w行。需要对主键增加上多元索引吗?
- [Title brushing] coco, who likes bananas
- QQ was stolen? The reason is
- 【刷题篇】避免洪水泛滥
猜你喜欢

"Persistent diseases" that cannot be solved in IM application development

智慧运维:基于 BIM 技术的可视化管理系统

Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone

【刷题篇】爱吃香蕉的珂珂

SQL考勤统计月报表
![[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)](/img/5a/eaa845f4332f0b8ee8b6409d6a79e8.png)
[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)

【刷题篇】避免洪水泛滥

Lifting scanning tool

一篇文章读懂关于企业IM的所有知识点

MySQL access denied, opened as Administrator
随机推荐
Read all the knowledge points about enterprise im in one article
Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone
[KALI] KALI系统、软件更新(附带镜像源)
半导体动态杂谈
Data Lake (11): Iceberg table data organization and query
为基础性语言摇旗呐喊
With the development of industrial Internet, the landing and application of the Internet has become wider
点击table的td单元格出现dialog弹窗,获取值后将值放回td单元格
What is erdma as illustrated by Coptic cartoon?
[Title brushing] heater
Yousi College: Six Sigma is not just statistics!
Dart 扩展特性
QQ 居然被盗了?原因在这......
[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)
重磅:国产IDE发布,由阿里研发,完全开源!
Numpy creates an empty array data = np empty(shape=[1, 64,64,3])
Simple understanding of the difference between get request and post submission
QQ was stolen? The reason is
[the path of system analyst] Chapter V software engineering (software process improvement)
Getting started with shell Basics