摘要
返回两个整数的差值。
语法
sub(<operands>)
说明
函数 sub()
返回两个整数的差值。 它从第一个操作数中减去第二个操作数。 可以嵌套对 的 sub()
调用以减去两个以上的整数。
示例
示例 1 - 减去两个整数
此示例文档演示如何使用 sub()
函数返回两个整数的差值。
# sub.example.1.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Subtract integers
type: Test/Echo
properties:
output: "[sub(7, 3)]"
dsc config get --document sub.example.1.dsc.config.yaml config get
results:
- name: Subtract integers
type: Test/Echo
result:
actualState:
output: 4
messages: []
hadErrors: false
参数
操作数
函数 sub()
需要恰好两个整数作为输入。
操作数可以是整数,也可以是返回整数的任何配置函数的输出。 使用逗号 () ,
分隔操作数。
Type: integer
Required: true
MinimumCount: 2
MaximumCount: 2
输出
函数 sub()
返回一个整数,表示 操作数之差。
Type: integer