Friday, 29 August 2014

PowerShell strings can't be $null (step in NullString)

I'd assumed that $[string]$arg = $null would set $arg to $null if no argument was specified ... but we all know what assumption makes :(

Summary

[string]$x = $null
$x -eq $null  # False !!!

[NullString]$x = $null
$x -eq $null  # True