Alex Rivera | Logout

PowerShell equality operator not a symmetric relation?

Asked 2012-04-17T05:55:57.210
9

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
Edit
Report

1 Answer

0

When you do "" -eq 0, it is same as "".equals(0) and it returns false.

0 -eq "" will try to convert "" to in and [int]"" is 0 and hence you get true.

answered 2012-04-17T06:17:36.330

Your Answer