Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Evaluation of Arrays to null

$
0
0

Hi everyone,

trying to look up some Values in a hashtable I stumbled upon a strange thing:

The values of the hashtable are integer-arrays, most of them consisting of only one number; yet I´ve made sure all of them are arrays, not sole integers. Eg:

$h["blah"]=@(0)
$h["blubb"]=@(1)
$h["umpf"]=@(0,0)

I'd like to ask if some key exists:

PS H:\> if ( $h["blah"] -ne $null ) { "yes" }
PS H:\> if ( $h["blubb"] -ne $null ) { "yes" }
yes
PS H:\> if ( $h["umpf"] -ne $null ) { "yes" }
yes
PS H:\> if ( $h["nix"] -ne $null ) { "yes" }
PS H:\>

or:

PS H:\>  if ( @(0) -ne $null ) { "yes" }
PS H:\>  if ( @(0) -eq $null ) { "yes" }
PS H:\> 

... it´s a feature, right ?

Any idea to get $h["blah"] -ne $null to be $true ?

Any help and comments are appreciated.
Thanks in advance!


Viewing all articles
Browse latest Browse all 6937

Trending Articles