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

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 {
}
主站蜘蛛池模板: 乡宁县| 青冈县| 长春市| 霍邱县| 昆明市| 富锦市| 平度市| 连南| 长岭县| 宁南县| 顺平县| 团风县| 蓬溪县| 兴义市| 綦江县| 天水市| 突泉县| 崇仁县| 东源县| 南华县| 高台县| 黄梅县| 苍梧县| 南昌市| 大洼县| 吴堡县| 龙山县| 阳曲县| 宁蒗| 内黄县| 绍兴市| 仲巴县| 河南省| 迁西县| 漯河市| 手机| 绥棱县| 南阳市| 华阴市| 富裕县| 德阳市|