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

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 {
}
主站蜘蛛池模板: 安多县| 根河市| 永修县| 桦南县| 新巴尔虎右旗| 炉霍县| 平邑县| 明星| 山东| 六枝特区| 衡南县| 黄大仙区| 麻栗坡县| 明溪县| 安远县| 武宁县| 云阳县| 华坪县| 西丰县| 抚远县| 高密市| 静乐县| 利川市| 精河县| 肃南| 蓬溪县| 孝昌县| 根河市| 和田市| 资兴市| 佛教| 巴南区| 金门县| 鄯善县| 东丽区| 武义县| 普陀区| 广丰县| 信丰县| 孝昌县| 营口市|