BREAK in nested Loops behaves weird
i found weird behavior of break in nested loops.
here test-code:
#1 :outerloop foreach ($x in 1..3) { 'x' + $x :innerloop foreach ($y in 1..8) { ' y' + $y if ($y -ge 5) { break innerloop } } } #2 :outerloop foreach ($x in 1..3) { 'x' + $x :innerloop foreach ($y in 1..8) { ' y' + $y if ($y -ge 5) { break noloop } } }
#1 breaks inner loop expected.
#2 breaks outer loop though specified not-existing label "noloop" break. expect error or warning. @ worst expect non-existing label ignored and the outer loop breaks.
does see logic behind behavior?
thanks. posted it @ uservoice:
http://windowsserver.uservoice.com/forums/301869-powershell
sorry. direct link here:
Windows Server > Windows PowerShell
Comments
Post a Comment