【发布时间】:2018-07-24 09:02:06
【问题描述】:
谁能解释为什么当从 powershell 函数返回 $false 时,您无法使用比较运算符来确定函数是否返回了 $false,但是当您返回 $true 时,比较结果为 $true?
function boolean {
return $false
}
boolean -eq $false
function boolean {
return $true
}
boolean -eq $true
>>>False
>>>True
您可以通过将函数调用设置为变量来解决此问题,但我想知道是否有人可以解释这里发生了什么?
function boolean {
return $false
}
$bool = boolean
$bool -eq $false
function boolean {
return $true
}
$bool = boolean
$bool -eq $true
>>>True
>>>True
【问题讨论】:
标签: powershell parsing syntax