diff --git a/examples/if-else/if-else.go b/examples/if-else/if-else.go index 4de7c47..f59795c 100644 --- a/examples/if-else/if-else.go +++ b/examples/if-else/if-else.go @@ -19,6 +19,12 @@ func main() { fmt.Println("8 is divisible by 4") } + // Logical operators like `&&` and `||` are often + // useful in conditions. + if 7%2 == 0 || 8%2 == 0 { + fmt.Println("either 8 or 7 are even") + } + // A statement can precede conditionals; any variables // declared in this statement are available in the current // and all subsequent branches. diff --git a/examples/if-else/if-else.hash b/examples/if-else/if-else.hash index 37363db..276f727 100644 --- a/examples/if-else/if-else.hash +++ b/examples/if-else/if-else.hash @@ -1,2 +1,2 @@ -d6a962236fc1296684cd1ffb2d95d131ed84abde -U7xcpdutgCJ +152124e287cd55e549bc29bcb8693bf260d1b3ab +hTOHdmUcUxz diff --git a/examples/if-else/if-else.sh b/examples/if-else/if-else.sh index 52ccc11..99f60cc 100644 --- a/examples/if-else/if-else.sh +++ b/examples/if-else/if-else.sh @@ -1,6 +1,7 @@ $ go run if-else.go 7 is odd 8 is divisible by 4 +either 7 or 8 are even 9 has 1 digit # There is no [ternary if](https://en.wikipedia.org/wiki/%3F:) diff --git a/public/if-else b/public/if-else index c394864..d40fe0d 100644 --- a/public/if-else +++ b/public/if-else @@ -42,7 +42,7 @@ straight-forward.

- +
package main
@@ -95,6 +95,20 @@ straight-forward.

+ + +

Logical operators like && and || are often +useful in conditions.

+ + + + +
    if 7%2 == 0 || 8%2 == 0 {
+        fmt.Println("either 8 or 7 are even")
+    }
+ + +

A statement can precede conditionals; any variables @@ -140,6 +154,7 @@ in Go, but that the braces are required.

$ go run if-else.go 
 7 is odd
 8 is divisible by 4
+either 7 or 8 are even
 9 has 1 digit
@@ -172,7 +187,7 @@ for basic conditions.