概要
2 つの整数を加算し、合計を返します。
構文
add(<operands>)
説明
関数は add() 、2 つの整数の合計を返します。 2 番目のオペランドを最初のオペランドに追加します。 への呼び出しを add() 入れ子にして、2 つ以上の整数を合計できます。
例
例 1 - 2 つの整数を追加する
このドキュメントの例では、 関数を add() 使用して 2 つの整数の合計を返す方法を示します。
# add.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Sum of 3 and 5
type: Microsoft.DSC.Debug/Echo
properties:
output: "[add(3, 5)]"
dsc config get --file add.example.1.dsc.config.yaml
results:
- name: Sum of 3 and 5
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: 8
messages: []
hadErrors: false
例 2 - 入れ子になった関数の出力を追加する
このドキュメントの例では、 関数を使用して、整数値を add() 返す入れ子になった構成関数の合計を返す方法を示します。
# add.example.2.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Add nested function outputs
type: Microsoft.DSC.Debug/Echo
properties:
output: "[add(mul(2,3), div(6,3))]"
dsc config get --file add.example.2.dsc.config.yaml
results:
- name: Add nested function outputs
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: 8
messages: []
hadErrors: false
パラメーター
オペランド
この関数は add() 、入力として 2 つの整数を受け取ります。
オペランドには、整数または整数を返す任意の構成関数の出力を指定できます。
オペランドをコンマ (,) で区切ります。
Type: integer
Required: true
MinimumCount: 2
MaximumCount: 2
出力
関数はadd()、オペランドの合計を表す整数を返します。
Type: integer
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。