PowerShell equality operator not a symmetric relation?

前端 未结 4 460
面向向阳花
面向向阳花 2021-01-17 21:00

Can someone please explain to me why the equality operator in PowerShell is not a symmetric relation??

PS> \"\" -eq 0
False
PS> 0 -eq \"\"
True
         


        
4条回答
  •  醉酒成梦
    2021-01-17 21:27

    It is how PowerShell tries to convert the type and then compare.

    Check this:

    $false -eq ""
    

    This returns True as well.

提交回复
热议问题