Bicep 提供 bool
用于将值转换为布尔值的函数。
Azure 资源管理器模板中的大多数逻辑函数都替换为 Bicep 中的 逻辑运算符 。
bool(arg1)
将参数转换为布尔值。
命名空间: sys。
参数 | 必选 | 类型 | DESCRIPTION |
---|---|---|---|
arg1 | 是的 | 字符串或整数 | 要转换为布尔值的值。 字符串值“true”与大写字符和小写字符的任何组合(例如“True”、“TRUE”、“tRue”、“true”)被视为等效值,否则true 表示布尔值false 。 整数值 0 被视为 false ,所有其他整数被视为 true 。 |
转换后的值的布尔值。
以下示例演示如何与字符串或整数一起使用 bool
。
output trueString1 bool = bool('true')
output trueString2 bool = bool('trUe')
output falseString1 bool = bool('false')
output falseString2 bool = bool('falSe')
output trueInt2 bool = bool(2)
output trueInt1 bool = bool(1)
output trueIntNeg1 bool = bool(-1)
output falseInt0 bool = bool(0)
上述示例中使用默认值的输出为:
名称 | 类型 | 价值 |
---|---|---|
trueString1 | 布尔值 | 是 |
trueString2 | 布尔值 | 是 |
falseString1 | 布尔值 | 假 |
falseString2 | 布尔值 | 假 |
trueInt2 | 布尔值 | 是 |
trueInt1 | 布尔值 | 是 |
trueIntNeg1 | 布尔值 | 是 |
falseInt | 布尔值 | 假 |
- 有关涉及逻辑值的其他作,请参阅 逻辑运算符。