当前位置:网站首页>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
边栏推荐
- mysql拒绝访问、管理员身份打开的
- 点击table的td单元格出现dialog弹窗,获取值后将值放回td单元格
- Read all the knowledge points about enterprise im in one article
- Complete TCP forwarding server (kernel linked list + mutex)
- 知识传播不能取代专业学习!
- Je suis à Foshan, où puis - je ouvrir un compte? L'ouverture d'un compte par téléphone mobile est - elle sécurisée?
- This editor will open source soon!
- Chapter 13 signal (III) - example demonstration
- navicat数据库建表是没有utf8选项。
- [the path of system analyst] Chapter V software engineering (software process improvement)
猜你喜欢
Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs
What network security problems are exposed when a large-scale QQ number theft event occurs?
More than 20 years after Hong Kong's return, Tupu digital twin Hong Kong Zhuhai Macao Bridge has shocked
SQL编程问题,测试用例不通过
Introduction to reverse commissioning - VA and RVA conversion in PE 04/07
Today's sleep quality record 80 points
“即服务”,企业数字化转型的必然选择
Basic syntax of unity script (1) - common operations of game objects
半导体动态杂谈
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
随机推荐
IM即时通讯应用开发中无法解决的“顽疾”
(8) JMeter component detailed once only controller
Dart extended feature
I want to ask how to open an account at China Merchants Securities? Is it safe to open a stock account through the link
This editor will open source soon!
STM32 porting the fish component of RT thread Standard Edition
exlipse同时操作多行。比如同时在多行同列输入相同的文字
【刷题篇】供暖器
"Persistent diseases" that cannot be solved in IM application development
MySQL如何将列合并?
Details of gets, fgetc, fgets, Getc, getchar, putc, fputc, putchar, puts, fputs functions
MySQL access denied, opened as Administrator
优思学院:六西格玛不只是统计!
Why can't the database table be written into data
Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance
【 scientific literature measurement 】 mining and visualization of keywords in foreign and Chinese Literature
一文讲清楚什么是类型化数组、ArrayBuffer、TypedArray、DataView等概念
一篇文章读懂关于企业IM的所有知识点
Optimization of unit test efficiency: why test programs? What are the benefits of testing?
嵌入式开发:5个可能不再被禁止的C特征