小编Jer*_*une的帖子

Why do PowerShell comparison operators not enumerate collections of size 1?

When checking variables and collections of variables for nullity, comparison operators seem to enumerate collections of size 2 or more:

> if ( @( $null, $null ) -eq $null ) { $True } else { $False }
True
Run Code Online (Sandbox Code Playgroud)

But they do not for collections of size 1:

> if ( @( $null ) -eq $null ) { $True } else { $False }
False
Run Code Online (Sandbox Code Playgroud)

I'm aware that it's best practice to null-compare using the left-hand side ($null -eq @( …

powershell

4
推荐指数
2
解决办法
153
查看次数

标签 统计

powershell ×1