-
-
Save bielawb/c794be8249e4028fecc18207778527a9 to your computer and use it in GitHub Desktop.
Rożnice między break i continue w switch dla kolekcji
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$użycieCpu = 40, 50, 60, 80, 90 | |
switch ($użycieCpu) { | |
50 { | |
"Połówka" | |
continue | |
} | |
{ $_ -gt 70 } { | |
"Gorąco! ($_)" | |
break | |
} | |
{ $_ -gt 50 } { | |
"Ciepło... ($_)" | |
continue | |
} | |
default { | |
"Ujdzie... ($_)" | |
} | |
} | |
<# | |
Na wyjściu brakuje 90 (break dla 'Gorąco' i 80): | |
Ujdzie... (40) | |
Połówka | |
Ciepło... (60) | |
Gorąco! (80) | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment