March 2019
Beginner to intermediate
324 pages
7h 17m
English
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 {}
Read now
Unlock full access