Why is equals “-eq” in PowerShell and not just “=”?

后端 未结 3 1056
长发绾君心
长发绾君心 2020-12-15 04:01

The constructs -ne, -eq, and -gt looks at least strange.

if ($true -eq $true){}

but not



        
3条回答
  •  攒了一身酷
    2020-12-15 04:54

    The operator = is already the assignment operator. In order not to confuse the comparison and the assignment operator they choose for another operator. In this case for -eq because this is already in use in other (UNIX) scripting languages.

提交回复
热议问题