- 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 {
}
推薦閱讀
- 多媒體CAI課件設(shè)計與制作導(dǎo)論(第二版)
- 軟件項目管理(第2版)
- LabVIEW入門與實戰(zhàn)開發(fā)100例
- Mastering Ember.js
- Selenium Design Patterns and Best Practices
- x86匯編語言:從實模式到保護模式(第2版)
- Python Data Analysis(Second Edition)
- 單片機應(yīng)用與調(diào)試項目教程(C語言版)
- Creating Data Stories with Tableau Public
- Fast Data Processing with Spark(Second Edition)
- TypeScript 2.x By Example
- Java程序設(shè)計基礎(chǔ)(第6版)
- Learning Kotlin by building Android Applications
- INSTANT EaselJS Starter
- Unity虛擬現(xiàn)實開發(fā)圣典