Skip to content

Commit

Permalink
Merge pull request #1226 from PrzemyslawKlys/patch-1
Browse files Browse the repository at this point in the history
Update PossibleIncorrectComparisonWithNull.md
  • Loading branch information
JamesWTruher authored May 16, 2019
2 parents b5648de + 6447bf8 commit 9a557de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion RuleDocumentation/PossibleIncorrectComparisonWithNull.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
To ensure that PowerShell performs comparisons correctly, the `$null` element should be on the left side of the operator.

There are a number of reasons why this should occur:
* `$null` is a scalar. When the input (left side) to an operator is a scalar value, comparison operators return a Boolean value. When the input is a collection of values, the comparison operators return any matching values, or an empty array if there are no matches in the collection. The only way to reliably check if a value is `$null` is to place `$null` on the left side of the operator so that a scalar comparison is perfomed.
* `$null` is a scalar. When the input (left side) to an operator is a scalar value, comparison operators return a Boolean value. When the input is a collection of values, the comparison operators return any matching values, or an empty array if there are no matches in the collection. The only way to reliably check if a value is `$null` is to place `$null` on the left side of the operator so that a scalar comparison is performed.
* PowerShell will perform type casting left to right, resulting in incorrect comparisons when `$null` is cast to other scalar types.

## How
Expand Down

0 comments on commit 9a557de

Please sign in to comment.