Ternary operator

ID248
Link ReferenceNot set
Link CreditsNot set
Link Technical DocumentationNot set
PlCodelangPowerShell
PlGroupFallunterscheidung
PlItemTitleTernary operator
Code## Example from here: https://www.kongsli.net/2012/02/23/powershell-another-alternative-to-ternary-operator/

$thisVar='OK'
$resultVar = @{$true=1;$false=2}[$thisVar -eq 'OK']

// same as if-else construction
if ($thisVar -eq 'OK')
{
$resultVar = 1;
}
else
{
$resultVar = 2;
}
Result Example