Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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