Powershell - if($variable) 测试什么? [英] Powershell - What does if($variable) test for?
本文介绍了Powershell - if($variable) 测试什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Powershell 中,if($variable)
测试什么?这是测试变量是否已设置、为空、为真还是其他?
In Powershell, what does if($variable)
test for? Is this testing if the variable is set, is null, is true, or something else?
推荐答案
它测试变量是否为真或非布尔变量是否可以合并为真.例如,每个都返回 false:
It tests whether the variable is true or whether a non-Boolean variable can be coalesced to true. For example, each of these return false:
$var #uninitialized
$var = ""
$var = $false
$var = 0
这些都返回真:
$var = "something"
$var = $true
$var = 1 #or any non-zero number
这篇关于Powershell - if($variable) 测试什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文