Ternary operator
ID | 248 |
---|---|
Link Reference | Not set |
Link Credits | Not set |
Link Technical Documentation | Not set |
PlCodelang | PowerShell |
PlGroup | Fallunterscheidung |
PlItemTitle | Ternary 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 |