当前位置:网站首页>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之后,条件语句之前,可以添加变量初始化语句,使用;进行分隔
边栏推荐
- WinDbg analysis dump file
- Driver and application communication
- Unity功能——Unity离线文档下载及使用
- The difference between RAR and zip files
- Using multipleoutputs to output multiple files in MapReduce
- UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
- Introduction to redis master-slave, sentinel and cluster mode
- The markdown file obtains the pictures of the network and stores them locally and modifies the URL
- 视觉上位系统设计开发(halcon-winform)-3.图像控件
- 找映射关系
猜你喜欢
Halcon and WinForm study section 1
VS2017通过IP调试驱动(双机调试)
秒杀系统3-商品列表和商品详情
Subclass hides the function with the same name of the parent class
软件逆向破解入门系列(1)—xdbg32/64的常见配置及功能窗口
Creation and destruction of function stack frames
[cloud native training camp] module VIII kubernetes life cycle management and service discovery
Wechat payment -jsapi: code implementation (payment asynchronous callback, Chinese parameter solution)
Kubernetes 进阶训练营 Pod基础
Automatic generation of client code from flask server code -- Introduction to flask native stubs Library
随机推荐
Construction of operation and maintenance system
高并发下之redis锁优化实战
leetcode_ Power of Four
CString中使用百分号
《微服务设计》读书笔记(上)
Driver and application communication
Puppet automatic operation and maintenance troubleshooting cases
互斥对象与临界区的区别
详解指针进阶2
秒杀系统1-登录功能
视觉上位系统设计开发(halcon-winform)-1.流程节点设计
详解指针进阶1
GCC cannot find the library file after specifying the link library path
App移动端测试【5】文件的写入、读取
Popular understanding of decision tree ID3
Visual upper system design and development (Halcon WinForm) -4 Communication management
Redis single thread problem forced sorting layman literacy
Unity功能——Unity离线文档下载及使用
Seckill system 3- product list and product details
Redis主从、哨兵、集群模式介绍