当前位置:网站首页>Go语言自学系列 | golang中的if else语句
Go语言自学系列 | golang中的if else语句
2022-07-03 15:34:00 【51CTO】
视频来源:B站《golang入门到项目实战 [2021最新Go语言教程,没有废话,纯干货!持续更新中...]》
一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴: Go语言自学系列 | 汇总_COCOgsta的博客-CSDN博客
go语言中的if else语句可以根据给定条件二选一。
go语言的if else语句语法
go语言if else语句实例
比较两个数的大小
运行结果
判断一个数是奇数还是偶数
运行结果
判断一个人是否成年
运行结果
特殊写法,在if前面添加执行语句
运行结果
go语言if语句使用提示:
- 不需使用括号将条件包含起来
- 大括号{}必须存在,即使只有一行语句
- 左括号必须在if或else的同一行
- 在if之后,条件语句之前,可以添加变量初始化语句,使用;进行分隔
边栏推荐
- Popular understanding of decision tree ID3
- The difference between RAR and zip files
- 需要知道的字符串函数
- Digital image processing -- popular understanding of corrosion and expansion
- Summary of JVM knowledge points
- The state does not change after the assignment of El switch
- Calibre LVL
- Visual host system design and development (Halcon WinForm)
- Can‘t connect to MySQL server on ‘localhost‘
- Visual upper system design and development (Halcon WinForm) -5 camera
猜你喜欢
Halcon与Winform学习第二节
整形和浮点型是如何在内存中的存储
The state does not change after the assignment of El switch
Vs2017 is driven by IP debugging (dual machine debugging)
qt使用QZxing生成二维码
Jvm-05-object, direct memory, string constant pool
Visual upper system design and development (Halcon WinForm) -5 camera
秒杀系统3-商品列表和商品详情
Seckill system 3- product list and product details
Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
随机推荐
《微服务设计》读书笔记(下)
Jvm-03-runtime data area PC, stack, local method stack
Halcon and WinForm study section 1
C语言刷题~Leetcode与牛客网简单题
The difference between RAR and zip files
找映射关系
Redis lock Optimization Practice issued by gaobingfa
redis单线程问题强制梳理门外汉扫盲
Visual upper system design and development (Halcon WinForm) -6 Nodes and grids
Puppet automatic operation and maintenance troubleshooting cases
How to use annotations such as @notnull to verify and handle global exceptions
Jvm-09 byte code introduction
Problems of CString in multithreading
[cloud native training camp] module 7 kubernetes control plane component: scheduler and controller
Digital image processing -- popular understanding of corrosion and expansion
Popular understanding of linear regression (I)
Tensorflow realizes verification code recognition (I)
Popular understanding of decision tree ID3
子类隐藏父类的同名函数
详解指针进阶2