Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created June 23, 2020 23:05
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/abb39e14251091e343b9901d37173ce5 to your computer and use it in GitHub Desktop.
Save bielawb/abb39e14251091e343b9901d37173ce5 to your computer and use it in GitHub Desktop.
Switch - break bez kolekcji
$procentWolnejPamięci = 30
switch ($procentWolnejPamięci) {
{ $_ -gt 70 } {
'OK'
break
}
{ $_ -gt 50 } {
'Tak sobie...'
break
}
{ $_ -gt 20 } {
'Kiepsko'
break
}
{ $_ -gt 10 } {
'Oops?'
break
}
default {
'Pożar!'
}
}
# Na wyjściu tylko "Kiepsko", mimo że blok skryptu przy 'Oops' też zwróciłby wartość logiczną $true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment