Skip to content

Instantly share code, notes, and snippets.

@mkropat
Created May 2, 2019 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkropat/f2c2d93beed7f223ed1da4d114438504 to your computer and use it in GitHub Desktop.
Save mkropat/f2c2d93beed7f223ed1da4d114438504 to your computer and use it in GitHub Desktop.
PowerShell WTF
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
#}
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