3.2 其实和if的Else一样,如下英文解释
In a similar manner as an If statement, the Switch statement executes code only if at least one of
the specified conditions is met. The keyword, which for the If statement is called Else, is called
default for Switch statement. When no other condition matches, the default clause is run.
#>
$value02= 15 # 请尝给变量value02分配 5,6,7,15这些值时,返回的结果
switch ($value02)
{
{$_ -le 5} {"$_ is a number from 1 to 5"}
6 {"Number is 6"}
{ (($_ -gt 6) -and ($_ -le 10)) } { "$_ is a number from 7 to 10" }
default { "$_ is a number outside the range of from 1 to 10"}
4.2 英文解释如下
If you'd like to receive only one result, while consequently making sure that only the first applicable
condition is performed, then append the break statement to the code.
In fact, now you get only the first applicable result. The keyword break indicates that no more
processing will occur and the Switch statement will exit.