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

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 {
}
主站蜘蛛池模板: 长子县| 台山市| 徐闻县| 楚雄市| 湟源县| 视频| 德令哈市| 门头沟区| 扎鲁特旗| 宁南县| 临沂市| 棋牌| 揭东县| 抚松县| 沁源县| 涡阳县| 田阳县| 壶关县| 砀山县| 托克逊县| 梁平县| 容城县| 三台县| 称多县| 竹北市| 浙江省| 阿坝县| 台东县| 肥乡县| 五台县| 乌鲁木齐县| 广东省| 达孜县| 资阳市| 长乐市| 论坛| 伊宁县| 阳原县| 华坪县| 错那县| 家居|