PowerShell 中的布尔文字 [英] Boolean literals in PowerShell
本文介绍了PowerShell 中的布尔文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PowerShell 中的布尔文字是什么?
What are the Boolean literals in PowerShell?
推荐答案
$true
和 $false
.
不过,这些都是常量.布尔值没有语言级别的文字.
Those are constants, though. There are no language-level literals for Booleans.
根据您需要它们的位置,您还可以使用任何强制为布尔值的东西,如果类型必须是布尔值,例如,在需要布尔值的方法调用中(并且没有冲突重载)或条件语句.例如,大多数非空对象为真.null
、空字符串、空数组和数字 0
都是假的.
Depending on where you need them, you can also use anything that coerces to a Boolean value, if the type has to be Boolean, e.g., in method calls that require Boolean (and have no conflicting overload), or conditional statements. Most non-null objects are true, for example. null
, empty strings, empty arrays and the number 0
are false.
这篇关于PowerShell 中的布尔文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文