From 95be6d2d3c90d559e886917910f61a759e516c86 Mon Sep 17 00:00:00 2001 From: Inanc Gumus Date: Sun, 11 Nov 2018 15:59:28 +0300 Subject: [PATCH] fix: constants and if code and quizzes --- .../solution/without-comments/main.go | 4 +-- 11-if/questions/2-logical-operators.md | 30 +++++++++---------- 11-if/questions/3-if.md | 8 ++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/10-constants/03-refactor-feet-to-meters/solution/without-comments/main.go b/10-constants/03-refactor-feet-to-meters/solution/without-comments/main.go index 44b4f9d..aa9d110 100644 --- a/10-constants/03-refactor-feet-to-meters/solution/without-comments/main.go +++ b/10-constants/03-refactor-feet-to-meters/solution/without-comments/main.go @@ -19,8 +19,8 @@ import ( func main() { const ( - feetInMeters = 0.3048 - feetInYards = feetInMeters / 0.9144 + feetInMeters float64 = 0.3048 + feetInYards = feetInMeters / 0.9144 ) arg := os.Args[1] diff --git a/11-if/questions/2-logical-operators.md b/11-if/questions/2-logical-operators.md index 2230cdb..e1b95ad 100644 --- a/11-if/questions/2-logical-operators.md +++ b/11-if/questions/2-logical-operators.md @@ -102,8 +102,8 @@ fmt.Println(a || b) ```go // Let's say that there are two functions like this: // -// super() which returns true and prints "super ". -// duper() which returns false and prints "duper ". +// isOn() which returns true and prints "on ". +// isOff() which returns false and prints "off ". // // Remember: Logical operators short-circuit. @@ -111,37 +111,37 @@ package main import "fmt" func main() { - _ = duper() && super() - _ = super() || duper() + _ = isOff() && isOn() + _ = isOn() || isOff() } // Don't mind about these functions. // Just focus on the problem. // They are here just for you to understand what's going on better. -func super() bool { - fmt.Print("super ") +func isOn() bool { + fmt.Print("on ") return true } -func duper() bool { - fmt.Print("duper ") +func isOff() bool { + fmt.Print("off ") return false } ``` -1. "super duper super duper " -2. "duper super " *CORRECT* -3. "duper super super duper " -4. "super duper " +1. "on off on off " +2. "off on " *CORRECT* +3. "off on on off " +4. "on off " > **1, 3:** Remember: Logical operators short-circuit. > **2:** That's right. > -> In: `duper() && super()`, `duper()` returns false, so, logical AND operator short-circuits and doesn't call `super()`; so it prints: `"duper "`. +> In: `isOff() && isOn()`, `isOff()` returns false, so, logical AND operator short-circuits and doesn't call `isOn()`; so it prints: `"off "`. > -> Then, in: `super() || duper()`, `super()` returns true, so, logical OR operator short circuits and doesn't call `duper()`; so it prints `"super "`. +> Then, in: `isOn() || isOff()`, `isOn()` returns true, so, logical OR operator short circuits and doesn't call `isOff()`; so it prints `"on "`. > **4:** Think again. -Example program is [here](https://play.golang.org/p/C-syhwgXSx2). \ No newline at end of file +Example program is [here](https://play.golang.org/p/6z3afaOf7yT). \ No newline at end of file diff --git a/11-if/questions/3-if.md b/11-if/questions/3-if.md index 5938054..807eb1e 100644 --- a/11-if/questions/3-if.md +++ b/11-if/questions/3-if.md @@ -15,10 +15,10 @@ if (mood == "perfect") { } ``` -1. `if {mood == perfect}` -2. `if [mood == perfect]` -3. `if mood = perfect` -4. `if mood == perfect` *CORRECT* +1. `if {mood == "perfect"}` +2. `if [mood == "perfect"]` +3. `if mood = "perfect"` +4. `if mood == "perfect"` *CORRECT* > **1, 2:** That's a syntax error. Try again. >