From c14d932875b32dbb693adca50f0eb2d538b26f7d Mon Sep 17 00:00:00 2001 From: Bobby Reed Date: Thu, 9 May 2019 10:58:04 -0400 Subject: [PATCH] Fixes #3709 - rewrite about_Continue for clarity (#4284) --- .../About/about_Continue.md | 37 +++++++++++++++---- .../About/about_Continue.md | 33 ++++++++++++++--- .../About/about_Continue.md | 34 +++++++++++++---- .../About/about_Continue.md | 34 +++++++++++++---- .../About/about_Continue.md | 34 ++++++++++++++--- 5 files changed, 138 insertions(+), 34 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md index 5f55a5db4023..3996b539e3cc 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md @@ -1,5 +1,5 @@ ---- -ms.date: 06/25/2017 +--- +ms.date: 5/9/2019 schema: 2.0.0 keywords: powershell,cmdlet title: about_Continue @@ -22,30 +22,51 @@ statement in a script. For information about labels, see [about_Break](about_Break.md). In the following example, program flow returns to the top of the While loop -if the $ctr variable is equal to 5. As a result, all the numbers between 1 +if the `$ctr` variable is equal to 5. As a result, all the numbers between 1 and 10 are displayed except for 5: ```powershell while ($ctr -lt 10) { $ctr += 1 - if ($ctr -eq 5) {Continue} + if ($ctr -eq 5) + { + Continue + } + Write-Host -Object $ctr } ``` -Note that in a `For` loop, execution continues at the first line in the -loop. If the arguments of the `For` statement test a value that is modified -by the `For` statement, an infinite loop may result. +When using a `For` loop, execution continues at the `` statement, +followed by the `` test. In the example below, an infinite loop +will not occur because the decrement of `$i` occurs after the `Continue` +keyword. + +```powershell +# +for ($i = 0; $i -lt 10; $i++) +{ + Write-Host -Object $i + if ($i -eq 5) + { + continue + # Will not result in an infinite loop. + $i--; + } +} +``` ## SEE ALSO [about_Break](about_Break.md) +[about_For](about_For.md) + [about_Comparison_Operators](about_Comparison_Operators.md) [about_Throw](about_Throw.md) [about_Trap](about_Trap.md) -[about_Try_Catch_Finally](about_Try_Catch_Finally.md) \ No newline at end of file +[about_Try_Catch_Finally](about_Try_Catch_Finally.md) diff --git a/reference/4.0/Microsoft.PowerShell.Core/About/about_Continue.md b/reference/4.0/Microsoft.PowerShell.Core/About/about_Continue.md index 1db1ad2a2583..8d6dfb9f5ed0 100644 --- a/reference/4.0/Microsoft.PowerShell.Core/About/about_Continue.md +++ b/reference/4.0/Microsoft.PowerShell.Core/About/about_Continue.md @@ -1,5 +1,5 @@ --- -ms.date: 06/25/2017 +ms.date: 5/9/2019 schema: 2.0.0 keywords: powershell,cmdlet title: about_Continue @@ -23,26 +23,47 @@ statement in a script. For information about labels, see [about_Break](about_Break.md). In the following example, program flow returns to the top of the While loop -if the $ctr variable is equal to 5. As a result, all the numbers between 1 +if the `$ctr` variable is equal to 5. As a result, all the numbers between 1 and 10 are displayed except for 5: ```powershell while ($ctr -lt 10) { $ctr += 1 - if ($ctr -eq 5) {Continue} + if ($ctr -eq 5) + { + Continue + } + Write-Host -Object $ctr } ``` -Note that in a `For` loop, execution continues at the first line in the -loop. If the arguments of the `For` statement test a value that is modified -by the `For` statement, an infinite loop may result. +When using a `For` loop, execution continues at the `` statement, +followed by the `` test. In the example below, an infinite loop +will not occur because the decrement of `$i` occurs after the `Continue` +keyword. + +```powershell +# +for ($i = 0; $i -lt 10; $i++) +{ + Write-Host -Object $i + if ($i -eq 5) + { + continue + # Will not result in an infinite loop. + $i--; + } +} +``` ## SEE ALSO [about_Break](about_Break.md) +[about_For](about_For.md) + [about_Comparison_Operators](about_Comparison_Operators.md) [about_Throw](about_Throw.md) diff --git a/reference/5.0/Microsoft.PowerShell.Core/About/about_Continue.md b/reference/5.0/Microsoft.PowerShell.Core/About/about_Continue.md index 1db1ad2a2583..79c91451840a 100644 --- a/reference/5.0/Microsoft.PowerShell.Core/About/about_Continue.md +++ b/reference/5.0/Microsoft.PowerShell.Core/About/about_Continue.md @@ -1,10 +1,9 @@ --- -ms.date: 06/25/2017 +ms.date: 5/9/2019 schema: 2.0.0 keywords: powershell,cmdlet title: about_Continue --- - # About Continue ## SHORT DESCRIPTION @@ -23,26 +22,47 @@ statement in a script. For information about labels, see [about_Break](about_Break.md). In the following example, program flow returns to the top of the While loop -if the $ctr variable is equal to 5. As a result, all the numbers between 1 +if the `$ctr` variable is equal to 5. As a result, all the numbers between 1 and 10 are displayed except for 5: ```powershell while ($ctr -lt 10) { $ctr += 1 - if ($ctr -eq 5) {Continue} + if ($ctr -eq 5) + { + Continue + } + Write-Host -Object $ctr } ``` -Note that in a `For` loop, execution continues at the first line in the -loop. If the arguments of the `For` statement test a value that is modified -by the `For` statement, an infinite loop may result. +When using a `For` loop, execution continues at the `` statement, +followed by the `` test. In the example below, an infinite loop +will not occur because the decrement of `$i` occurs after the `Continue` +keyword. + +```powershell +# +for ($i = 0; $i -lt 10; $i++) +{ + Write-Host -Object $i + if ($i -eq 5) + { + continue + # Will not result in an infinite loop. + $i--; + } +} +``` ## SEE ALSO [about_Break](about_Break.md) +[about_For](about_For.md) + [about_Comparison_Operators](about_Comparison_Operators.md) [about_Throw](about_Throw.md) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Continue.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Continue.md index 1db1ad2a2583..79c91451840a 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Continue.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Continue.md @@ -1,10 +1,9 @@ --- -ms.date: 06/25/2017 +ms.date: 5/9/2019 schema: 2.0.0 keywords: powershell,cmdlet title: about_Continue --- - # About Continue ## SHORT DESCRIPTION @@ -23,26 +22,47 @@ statement in a script. For information about labels, see [about_Break](about_Break.md). In the following example, program flow returns to the top of the While loop -if the $ctr variable is equal to 5. As a result, all the numbers between 1 +if the `$ctr` variable is equal to 5. As a result, all the numbers between 1 and 10 are displayed except for 5: ```powershell while ($ctr -lt 10) { $ctr += 1 - if ($ctr -eq 5) {Continue} + if ($ctr -eq 5) + { + Continue + } + Write-Host -Object $ctr } ``` -Note that in a `For` loop, execution continues at the first line in the -loop. If the arguments of the `For` statement test a value that is modified -by the `For` statement, an infinite loop may result. +When using a `For` loop, execution continues at the `` statement, +followed by the `` test. In the example below, an infinite loop +will not occur because the decrement of `$i` occurs after the `Continue` +keyword. + +```powershell +# +for ($i = 0; $i -lt 10; $i++) +{ + Write-Host -Object $i + if ($i -eq 5) + { + continue + # Will not result in an infinite loop. + $i--; + } +} +``` ## SEE ALSO [about_Break](about_Break.md) +[about_For](about_For.md) + [about_Comparison_Operators](about_Comparison_Operators.md) [about_Throw](about_Throw.md) diff --git a/reference/6/Microsoft.PowerShell.Core/About/about_Continue.md b/reference/6/Microsoft.PowerShell.Core/About/about_Continue.md index 11bc0ce9a764..79c91451840a 100644 --- a/reference/6/Microsoft.PowerShell.Core/About/about_Continue.md +++ b/reference/6/Microsoft.PowerShell.Core/About/about_Continue.md @@ -1,5 +1,5 @@ --- -ms.date: 06/25/2017 +ms.date: 5/9/2019 schema: 2.0.0 keywords: powershell,cmdlet title: about_Continue @@ -7,6 +7,7 @@ title: about_Continue # About Continue ## SHORT DESCRIPTION + Describes how the `Continue` statement immediately returns the program flow to the top of a program loop. @@ -21,26 +22,47 @@ statement in a script. For information about labels, see [about_Break](about_Break.md). In the following example, program flow returns to the top of the While loop -if the $ctr variable is equal to 5. As a result, all the numbers between 1 +if the `$ctr` variable is equal to 5. As a result, all the numbers between 1 and 10 are displayed except for 5: ```powershell while ($ctr -lt 10) { $ctr += 1 - if ($ctr -eq 5) {Continue} + if ($ctr -eq 5) + { + Continue + } + Write-Host -Object $ctr } ``` -Note that in a `For` loop, execution continues at the first line in the -loop. If the arguments of the `For` statement test a value that is modified -by the `For` statement, an infinite loop may result. +When using a `For` loop, execution continues at the `` statement, +followed by the `` test. In the example below, an infinite loop +will not occur because the decrement of `$i` occurs after the `Continue` +keyword. + +```powershell +# +for ($i = 0; $i -lt 10; $i++) +{ + Write-Host -Object $i + if ($i -eq 5) + { + continue + # Will not result in an infinite loop. + $i--; + } +} +``` ## SEE ALSO [about_Break](about_Break.md) +[about_For](about_For.md) + [about_Comparison_Operators](about_Comparison_Operators.md) [about_Throw](about_Throw.md)