Provide a native ternary operator
It would be very nice and convenient if PowerShell had a native ternary operator like C# does (https://msdn.microsoft.com/en-us/library/zakwfxx4(v=vs.100).aspx).
Basically it would allow you to write a short-hand if-else statement, so instead of having to write:
$x = $y.Property1
$x = $y.Property2
you could just write:
$x = $someBoolCondition ? $y.Property1 : $y.Property2
This operator is fairly standard in many programming languages, so it would be awesome if PowerShell could come up to speed with it as well. Thanks.
Tim Curwick commented
It isn't exactly what you are looking for, but this syntax works:
( "False result", "True result" )[$BoolTest]
For your example, it would be:
$x = ( $y.Property2, $y.Property1 )[$someBoolCondition]
PowerShell converts the boolean to an int32, 1 for $True, 0 for $False, and uses the result to index into the array of choices.
To use an actual conditional, wrap it in parentheses within the square brackets:
( "False result", "True result")[( $A -lt 10 )]