diff --git a/src/11-if-else.go b/src/11-if-else.go new file mode 100644 index 0000000..64643cc --- /dev/null +++ b/src/11-if-else.go @@ -0,0 +1,16 @@ + // If/Else + +package main + +func main() { + if 7 % 2 == 0 { // If/else is straightford. Note that there are no + println("even") // enclosing parenthesis around the condition. + } else { // Also, there is no ternary operator (`?`) in Go. + println("odd") + } +} + +/* +$ go run 11-if-else.go +odd +*/ diff --git a/src/11-if.go b/src/11-if.go deleted file mode 100644 index 2da68d0..0000000 --- a/src/11-if.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import "fmt" - -func main() { - i := 1 - for i <= 10 { - if i % 2 == 0 { - fmt.Println("even") - } else { - fmt.Println("odd") - } - i = i + 1 - } -}