diff --git a/guide/english/csharp/break/index.md b/guide/english/csharp/break/index.md index 0dc09f694d..41ed4d6acd 100644 --- a/guide/english/csharp/break/index.md +++ b/guide/english/csharp/break/index.md @@ -8,7 +8,7 @@ The `break` statement terminates the enclosing loop or switch statement in which In the first example, when the value of i is 3, the break statement is executed, which causes the execution of the loop to be terminated. -## Example +## Example 1 ``` int[] array = { 1, 2, 3, 4, 5 }; for (int i = 0; i < array.Length; i++) @@ -26,7 +26,7 @@ for (int i = 0; i < array.Length; i++) ``` In the second example, a break statement is included at the end of each case. This executes the statements in the case without continuing to the next case. Without the break statement, the program would continue to execute the next case and would not function as intended. -## Example +## Example 2 ``` switch (exampleVariable) { @@ -68,3 +68,37 @@ switch (exampleVariable) > default > This only shows in the Default Example ``` +In the third example, we make use of an infinite `while` loop, which prompts the user for the best song of all time. When the user finally enters "Ocean Man", a `break` statement is used, and the infinite `while` loop is exited. + +## Example 3 +``` +while (true) +{ + Console.WriteLine("What is the greatest song of all time? Be honest--I can wait all day!"); + string response = Console.ReadLine(); + if (response == "Ocean Man") + { + Console.WriteLine("Good, I agree!"); + break; + } + else Console.WriteLine("That's not the greatest song! Try again!"); +} + +``` + +## Output (if the user enters "Ocean Man" right away): +``` +> What is the greatest song of all time? Be honest--I can wait all day! +Ocean Man +> Good, I agree! +``` + +## Output (if the user enters "Darude Sandstorm" the first time, then "Ocean Man"): +``` +> What is the greatest song of all time? Be honest--I can wait all day! +Darude Sandstorm +> That's not the greatest song! Try again! +> What is the greatest song of all time? Be honest--I can wait all day! +Ocean Man +> Good, I agree! +``` diff --git a/guide/english/csharp/continue/index.md b/guide/english/csharp/continue/index.md index becff44742..294cb828be 100644 --- a/guide/english/csharp/continue/index.md +++ b/guide/english/csharp/continue/index.md @@ -8,6 +8,7 @@ The `continue` statement passes control to the next iteration inside a loop. In this example, when the value of i is 2, the next statement within the loop is skipped. +Note: When you execute a `continue` statement, you're effectively bypassing whatever code comes after it (in terms of execution) within the loop. This, along with the `break` statement, are very useful when working with loops. ## Example ``` int[] array = { 1, 2, 3, 4, 5 }; @@ -17,7 +18,7 @@ for (int i = 0; i < array.Length; i++) { continue; } - Console.WriteLine("Item on index {0} is {1}", i, array[i]); + Console.WriteLine("Item on index {0} is {1}", i, array[i]); } ``` diff --git a/guide/english/php/if-else-statement/index.md b/guide/english/php/if-else-statement/index.md index d762bf521f..f06af2d3dc 100644 --- a/guide/english/php/if-else-statement/index.md +++ b/guide/english/php/if-else-statement/index.md @@ -16,7 +16,7 @@ If/Else is a conditional statement where depending on the truthiness of a condit statement2; } ``` -> **Note:** The `else` statement is optional. +> **Note:** You can nest as many statements in an "if" block as you'd like; you are not limited to the amount in the examples. ## If/Else Statement ``` @@ -30,7 +30,7 @@ If/Else is a conditional statement where depending on the truthiness of a condit statement4; } ``` -> **Note:** `elseif` should always be written as one word. +> **Note:** The `else` statement is optional. ## If/Elseif/Else Statement ``` @@ -46,6 +46,7 @@ If/Else is a conditional statement where depending on the truthiness of a condit statement5; } ``` +> **Note:** `elseif` should always be written as one word. ## Nested If/Else Statement ``` @@ -87,6 +88,7 @@ For instance: echo 'One condition is true, and one condition is false!'; } ``` +> **Note:** It's a good practice to wrap individual conditions in parens when you have more than one (it can improve readability). ## Ternary Operators diff --git a/guide/english/python/escape-sequences/index.md b/guide/english/python/escape-sequences/index.md index 2ad9218c50..6619735566 100644 --- a/guide/english/python/escape-sequences/index.md +++ b/guide/english/python/escape-sequences/index.md @@ -25,11 +25,14 @@ A _raw_ string can be used by prefixing the string with `r` or `R` which allows print(r"An odd number of backslashes at the end of a raw string will cause an error\") ^ SyntaxError: EOL while scanning string literal. - #Some more examples of escape sequences. - Escape Sequence -\\ Prints Backslash -\` Prints single-quote -\" Prints double quote -\a ASCII bell makes ringing the bell alert sounds ( eg. xterm ) -\b ASCII backspace ( BS ) removes previous character -\n Adds newline. + +## Some more examples of escape sequences. + +Escape Sequence <- Intended Character +- \\\ <- backslash +- \\' <- single quote / apostrophe +- \\" <- double quote / quotation mark +- \\a <- ASCII bell makes ringing the bell alert sounds ( eg. xterm ) +- \\b <- ASCII backspace ( BS ) removes previous character +- \\n <- newline +- \\r <- carriage return