PowerShell Continue statement Usage example

Source: Internet
Author: User

This article mainly introduced the PowerShell continue statement use example, this article directly to produce the example code, needs the friend may refer to under

When you use the "Continue" statement inside a loop, you can skip the current iteration of the loop and continue with the next iteration. If you use the break statement, all remaining iteration loops are skipped.

This raises the question of which loops are affected in a multi-tiered nested loop. By default, "Continue" only affects the inner loop, but you can also use "Continue" and "break" to point to a label on the outer loop.

?

1 2 3 4 5 6 7 8 9 10 11 : Outer Foreach ($element in (1..10)) {for ($x = 1000; $x-lt 1500; $x + +) {"Frequency $x Hz" [Console]::beep ($x, 500 Continue outer write-host ' you and I won't meet again unless you change the code '}}

Because the continue statement in the example above will be tuned to the outer loop, we will see 10 1000Hz of output, and if the continue statement is deleted, the number of loops will obviously increase and the write-host statement will not skip.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.