Hello,
Is there any plans for ternary implementation ? ( Logic1 ? Expression2 : Expression3 ![]()
Also, if this is ok:
$i = $j = $null
why this is not fine with PS
$i -eq $j -eq $null
but this is fine
$i = $j = 1
$i -eq $j -eq 1
Hello,
Is there any plans for ternary implementation ? ( Logic1 ? Expression2 : Expression3 ![]()
Also, if this is ok:
$i = $j = $null
why this is not fine with PS
$i -eq $j -eq $null
but this is fine
$i = $j = 1
$i -eq $j -eq 1
The ternary operator has been around for a few years in Powershell, but only in 7.x. If you’re using Windows Powershell 5.x then no it won’t be implemeneted since Microsoft isn’t adding anything new to 5.x
$i = 50
$j = 100
$i -gt $j ? "$i is greater than $j" : "$i is less than or equal to $j"
$i = $j = $null
$i -eq $j -eq $null
This evaluates to $i -eq $j = True (1)
1 -eq $null = False
$i = $j = 1
$i -eq $j -eq 1
This evaluates to $i -eq $j = True (1), 1 -eq 1 = True
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.