langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,30 @@
|
|||
# standard switch
|
||||
switch ($var) {
|
||||
1 { "Value was 1" }
|
||||
2 { "Value was 2" }
|
||||
default { "Value was something else" }
|
||||
}
|
||||
|
||||
# switch with wildcard matching
|
||||
switch -Wildcard ($var) {
|
||||
"a*" { "Started with a" }
|
||||
"*x" { "Ended with x" }
|
||||
}
|
||||
|
||||
# switch with regular expression matching
|
||||
switch -Regex ($var) {
|
||||
"[aeiou]" { "Contained a consonant" }
|
||||
"(.)\1" { "Contained a character twice in a row" }
|
||||
}
|
||||
|
||||
# switch allows for scriptblocks too
|
||||
switch ($var) {
|
||||
{ $_ % 2 -eq 0 } { "Number was even" }
|
||||
{ $_ -gt 100 } { "Number was greater than 100" }
|
||||
}
|
||||
|
||||
# switch allows for handling a file
|
||||
switch -Regex -File somefile.txt {
|
||||
"\d+" { "Line started with a number" }
|
||||
"\s+" { "Line started with whitespace" }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue