- 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 Oozie Essentials
- Visual C++串口通信開發入門與編程實踐
- 程序設計與實踐(VB.NET)
- TensorFlow Lite移動端深度學習
- 我的第一本算法書
- 數據結構(Java語言描述)
- Git高手之路
- Swift 3 New Features
- JavaScript入門經典
- C語言程序設計習題與實驗指導
- .NET 4.5 Parallel Extensions Cookbook
- 零代碼實戰:企業級應用搭建與案例詳解
- Delphi開發典型模塊大全(修訂版)
- Node.js實戰:分布式系統中的后端服務開發
- Wearable:Tech Projects with the Raspberry Pi Zero