Fix typos in 12 questions

This commit is contained in:
Firas Khalil Khana 2021-05-01 13:21:54 +03:00 committed by İnanç Gümüş
parent db99ec40df
commit 3d936bc773

View File

@ -1,14 +1,14 @@
## What's the difference between if and switch statements? ## What's the difference between if and switch statements?
1. If statement controls the execution flow but the switch statement does not 1. If statements control the execution flow but switch statements do not
2. If statement is much more readable alternative to a switch statement 2. If statements are much more readable alternatives to switch statements
3. Switch statement is much more readable alternative to a if statement *CORRECT* 3. Switch statements are much more readable alternatives to if statements *CORRECT*
> **1:** They both control the execution flow. > **1:** They both control the execution flow.
> >
> **2:** Sometimes true, but, for complex if statements, switch statement can make them much more readable. > **2:** Sometimes true, but, for complex if statements, switch statement can make them much more readable.
## What type of values you can use as a switch condition? ## What type of values can you use as a switch condition?
```go ```go
switch condition { switch condition {
// .... // ....
@ -22,7 +22,7 @@ switch condition {
> **4:** Unlike most other C based languages, in Go, a switch statement is actually a syntactic-sugar for a if statement. This means that, Go converts a switch statement into an if statement behind the scenes. So, any type of values can be used as a condition. > **4:** Unlike most other C based languages, in Go, a switch statement is actually a syntactic-sugar for a if statement. This means that, Go converts a switch statement into an if statement behind the scenes. So, any type of values can be used as a condition.
## What type of values you can use as the case conditions for the following switch statement? ## What type of values can you use as the case conditions for the following switch statement?
```go ```go
switch false { switch false {
case condition: case condition:
@ -37,7 +37,7 @@ case condition:
> **2:** Yes, you can only use bool values because in the example, the switch's condition is a bool. > **2:** Yes, you can only use bool values because in the example, the switch's condition is a bool.
## What type of values you can use as the case conditions for the following switch statement? ## What type of values can you use as the case conditions for the following switch statement?
```go ```go
switch "go" { switch "go" {
case condition: case condition:
@ -183,4 +183,4 @@ case n == 8:
2. "n is 8" 2. "n is 8"
3. "n is big" *CORRECT* 3. "n is big" *CORRECT*
> **3:** That's right! Switch runs top-to-bottom and case conditions run left-to-right. Here, 1st case's 1st condition expression (which is n > 5) will yield true, so the 1st case will be executed. > **3:** That's right! Switch runs top-to-bottom and case conditions run left-to-right. Here, 1st case's 1st condition expression (which is n > 5) will yield true, so the 1st case will be executed.