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
Post a Comment