-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Summary of the new feature/enhancement
As a scripter,
I want to use -is and -isnot when comparing a value against $null instead of -eq and -ne
so that the comparison always works, even with collections or with types that overload the equality operator.
For reference: https://youtu.be/TJiLhRPgyq4?list=PLReL099Y5nRd04p81Q7p5TtyjCrj9tz1t&t=373
Proposed technical implementation details (optional)
Update the implementation of the -is and -isnot operators such that they allow $null in addition to types on the right operand, and when comparing against null they simply use the C# is operator internally to perform the comparison (which they may do already, so this may be a very trivial change to make.
This change makes for a much more expressive syntax as well, which reads very well in PowerShell.
Here is what I want to work once this is implemented:
$x -is $null
$y -isnot $null
$collection | where Property -is $null
$collection | where Property -isnot $nullI plan on implementing this PR as part of Hacktoberfest.