Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created June 23, 2020 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bielawb/c794be8249e4028fecc18207778527a9 to your computer and use it in GitHub Desktop.
Save bielawb/c794be8249e4028fecc18207778527a9 to your computer and use it in GitHub Desktop.
Rożnice między break i continue w switch dla kolekcji
$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