Skip to content

Instantly share code, notes, and snippets.

@dmalikov
Created April 14, 2014 14:09
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 dmalikov/10651508 to your computer and use it in GitHub Desktop.
Save dmalikov/10651508 to your computer and use it in GitHub Desktop.
Wow so null very static such empty
$ powershell ./wut.ps1
String is null
String is null
String is empty
function main() {
if ($true) {
$s = $null
} else {
$s = "string"
}
if ($s -eq $null) { Write-Host "String is null" }
if ($s -eq "") { Write-Host "String is empty" }
do_something_boring $s
}
function do_something_boring($s) {
if ($s -eq $null) { Write-Host "String is null" }
if ($s -eq "") { Write-Host "String is empty" }
do_something_obvious $s
}
function do_something_obvious([string] $s) {
if ($s -eq $null) { Write-Host "String is null" }
if ($s -eq "") { Write-Host "String is empty" }
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment