What's the best alternative for VBScript's SELECT...CASE statement?
Say I've got something like this:
What I'm doing in PS is something like this:
Is this the "right" (or at least the most common) way to handle multiple values?
Say I've got something like this:
Code:
Select Case strCompany
Case "Company A","Company B"
'do something
Case "Company C"
'do something else
Case Else
'do this if all else fails
End Select
What I'm doing in PS is something like this:
Code:
$array1 = "Company A","Company B"
$array2 = "Company C"
switch ($company)
{
{$array1 -contains $_} <# $_ = whatever is in $company #>
{<# do this for companies contained in $array1 #>}
{$array2 -contains $_}
{<# do this for companies contained in $array2 #>}
default
{<# do this is if the company is unspecified #>}
}
Is this the "right" (or at least the most common) way to handle multiple values?