Boolean literals in PowerShell

前端 未结 3 996
陌清茗
陌清茗 2020-12-14 13:28

What are the boolean literals in PowerShell?

3条回答
  •  清歌不尽
    2020-12-14 14:31

    $true and $false.

    Those are constants, though. There are no language-level literals for booleans.

    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.

提交回复
热议问题