- Hands-On Full Stack Development with Go
- Mina Andrawos
- 116字
- 2021-07-02 12:33:32
The if statement
The if statement looks like this:
if <condition>{
}
So, let's assume we want to compare whether a value, x, is equal to 10. Here is what the syntax would look like:
if x == 10{
}
In Go, you can also execute some initialization in your if statement. Here is what this syntax would look like:
if x := getX(); x == 5{
}
Like other programming languages, an if statement is never complete without an else clause. Here is what an if else looks like in Go:
if x==5{
}else{
}
How about an else clause with a condition?
if x == 5{
}else if x >10{
} else {
}
推薦閱讀
- Apache ZooKeeper Essentials
- Python自動(dòng)化運(yùn)維快速入門(mén)
- Vue.js快跑:構(gòu)建觸手可及的高性能Web應(yīng)用
- Servlet/JSP深入詳解
- 0 bug:C/C++商用工程之道
- Kotlin Programming By Example
- C++程序設(shè)計(jì)教程(第2版)
- Learning Python Data Visualization
- Magento 2 Beginners Guide
- Mastering Android Studio 3
- 軟件工程與UML案例解析(第三版)
- Three.js權(quán)威指南:在網(wǎng)頁(yè)上創(chuàng)建3D圖形和動(dòng)畫(huà)的方法與實(shí)踐(原書(shū)第4版)
- Learning Cocos2d-JS Game Development
- 用Python動(dòng)手學(xué)統(tǒng)計(jì)學(xué)
- 劍指大數(shù)據(jù):企業(yè)級(jí)電商數(shù)據(jù)倉(cāng)庫(kù)項(xiàng)目實(shí)戰(zhàn)(精華版)