Using 'Continue'

You will find that "Continue" is a special instruction that you can use in loops to skip the remainder of a loop.

This next loop returns only numbers between 1 and 20 that are divisible by 4:

For($x=1; $x -lt 20; $x++) {
If ($x % 4) { continue }
$x
}

Twitter This Tip! ReTweet this Tip!


Posted Oct 08 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.