Created
May 2, 2019 13:21
-
-
Save mkropat/f2c2d93beed7f223ed1da4d114438504 to your computer and use it in GitHub Desktop.
PowerShell WTF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '[1, 2, 3]' | ConvertFrom-Json | measure | |
# Count: 1 | |
(echo '[1, 2, 3]' | ConvertFrom-Json) | measure | |
# Count: 3 | |
echo '[1, 2, 3]' | ConvertFrom-Json | ConvertTo-Json | |
#{ | |
# "value": [ | |
# 1, | |
# 2, | |
# 3 | |
# ], | |
# "Count": 3 | |
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS > [bool] ($null -eq $null) | |
True # Makes sense | |
PS > [bool] (@($null) -eq $null) | |
False # As expected, but not for the reason you think | |
PS > [bool] (@($null, $null) -eq $null) | |
True # What?!? | |
PS > [bool] (-null -eq @($null, $null)) | |
False # Hence, "$null should be on the left side of equality comparisons" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment