官术网_书友最值得收藏!

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 {
}
主站蜘蛛池模板: 安溪县| 平阳县| 定陶县| 图木舒克市| 黎川县| 长垣县| 朔州市| 太谷县| 江西省| 固始县| 安义县| 沧源| 民权县| 左权县| 杭锦后旗| 大田县| 饶平县| 新津县| 岗巴县| 余姚市| 长兴县| 乌恰县| 晋城| 柘城县| 阿拉善盟| 丽江市| 休宁县| 广昌县| 左云县| 微博| 哈尔滨市| 遂川县| 佳木斯市| 托克托县| 阳城县| 和平区| 平罗县| 渭源县| 钟祥市| 新沂市| 车险|