概要
結合された値の文字列を返します。
構文
concat(<inputValue>, <inputValue>[, <inputValue>...])
説明
関数は concat() 複数の値を結合し、連結された値を 1 つの文字列として返します。 各値はコンマで区切ります。 関数は concat() 可変個引数です。 関数には、少なくとも 2 つの値を渡す必要があります。 関数は、任意の数の引数を受け取ることができます。
関数は、結合文字なしで入力値を連結します。 文字列または文字列の配列のみを入力値として受け入れます。 入力値は同じ型である必要があります。 文字列と配列を同じ関数に渡すと、関数はエラーを発生させます。
例
例 1 - 文字列を連結する
構成では、 関数を concat() 使用して文字列 abc と を結合します。 def
# concat.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo 'abcdef'
type: Microsoft.DSC.Debug/Echo
properties:
output: "[concat('abc', 'def')]"
dsc config get --file concat.example.1.dsc.config.yaml
results:
- name: Echo 'abcdef'
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: abcdef
messages: []
hadErrors: false
例 2 - 文字列の配列を連結する
構成では、 関数を concat() 使用して、2 つの文字列配列から文字列の結合配列を返します。 YAML の折りたたまれた複数行構文を使用して、関数をより読みやすくします。
# concat.example.2.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo ['a', 'b', 'c', 'd', 'e', 'f']
type: Microsoft.DSC.Debug/Echo
properties:
output: >-
[concat(
createArray('a', 'b', 'c'),
createArray('d', 'e', 'f')
)]
dsc config get --file concat.example.2.dsc.config.yaml
results:
- name: Echo ['a', 'b', 'c', 'd', 'e', 'f']
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output:
- a
- b
- c
- d
- e
- f
messages: []
hadErrors: false
パラメーター
inputValue
関数は concat() 、同じ型の 2 つ以上の入力値を連結することを想定しています。 各値は、文字列または文字列の配列である必要があります。 一方の値が文字列で、もう一方の値が配列である場合、またはいずれかの値が文字列または文字列の配列でない場合、DSC は構成ドキュメントを検証するときにエラーを発生させます。
Type: [string, array(string)]
Required: true
MinimumCount: 2
MaximumCount: 18446744073709551615
出力
すべての inputValue が文字列の場合は、 concat()すべての inputValue が連結された 1 つの文字列を返します。 すべての inputValue が文字列の配列である場合は、 concat() 各入力配列の文字列を含むフラット化された配列を返します。
Type: [string, array]