Comparison in empty array and null in powershell -


code:

$arr=@()  if($arr -ne $null){"ne"} else{"e"}  if($null -ne $arr){"ne"} else{"e"}  

output:

e ne  

how possible ?

the first if compares each element of array $null , produces collection of non-null elements, in case empty, it's false , else displays e.

the second if compares single object $null object $arr , since $arr not $null (as object stores empty collection inside) displays ne.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -