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

html - How to custom Bootstrap grid height? -

javascript - pass values from mssql to views in node -

image - python get coordinates (pixels) of corresponding points from clicks -