当前位置:网站首页>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
边栏推荐
- (8)JMeter元件详解之 Once only Controller 仅一次控制器
- Introduction to reverse commissioning - VA and RVA conversion in PE 04/07
- 第四批入围企业公示——年度TOP100智能网联供应商评选
- Introduction to the renewal of substrate source code: the pallet alliance is incorporated into the main line,
- Inexplicable error occurred in unity's frequent switching branch result model
- Yousi College: Six Sigma is not just statistics!
- Service online governance
- Small exercise of process and signal
- Je suis à Foshan, où puis - je ouvrir un compte? L'ouverture d'un compte par téléphone mobile est - elle sécurisée?
- Golang template (text/template)
猜你喜欢

What network security problems are exposed when a large-scale QQ number theft event occurs?

How can I protect my private key?

Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)

一文讲清楚什么是类型化数组、ArrayBuffer、TypedArray、DataView等概念

Unity animator parameter

SQL考勤统计月报表

More than 20 years after Hong Kong's return, Tupu digital twin Hong Kong Zhuhai Macao Bridge has shocked

Shell programming overview

Google Earth Engine(GEE)——GHSL:全球人类住区层,建成网格 1975-1990-2000-2015 (P2016) 数据集

重磅:国产IDE发布,由阿里研发,完全开源!
随机推荐
随着产业互联网的发展,有关互联网的落地和应用也就变得宽阔了起来
Tencent two sides: @bean and @component are used on the same class. What happens?
Talk about Vue's two terminal diff algorithm, analysis of the rendering principle of the mobile terminal, and whether the database primary key must be self incremented? What scenarios do not suggest s
"Persistent diseases" that cannot be solved in IM application development
【Kubernetes系列】K8s设置MySQL8大小写不敏感
Introduction to the renewal of substrate source code: the pallet alliance is incorporated into the main line,
[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)
Comprehensively analyze the basic features and summary of free and paid SSH tools
数字时代,XDR(扩展检测与响应)的无限可能
【 scientific literature measurement 】 mining and visualization of keywords in foreign and Chinese Literature
Introduction to reverse commissioning - VA and RVA conversion in PE 04/07
SQL attendance statistics monthly report
Jetpack compose for perfect screen fit
navicat数据库建表是没有utf8选项。
Details of gets, fgetc, fgets, Getc, getchar, putc, fputc, putchar, puts, fputs functions
华为帐号多端协同,打造美好互联生活
Numpy creates an empty array data = np empty(shape=[1, 64,64,3])
Jetpack Compose 实现完美屏幕适配
Rpm2rpm packaging steps
IM即时通讯应用开发中无法解决的“顽疾”