Updated on 2023-12-13 GMT+08:00

select

The select function can be used to obtain the object with a specified subscript from an array structure. Generally, this function is used together with the split function.

Syntax

select: [index, list]

Parameters

Table 1 Parameters

Parameter

Description

index

Subscript, which is used to obtain the specified elements in an array. If the subscript is not in the range supported by the array, an error is reported.

list

Array structure, which cannot be empty.

Return Values

Objects in the corresponding positions in an array are returned.

Examples

The following describes how to use the select function to obtain the specified object:

inputs:
  source:
    default: "a,b,c,d,e,f,g"
node_templates: 
  test: 
    type: HuaweiCloud.AOS.Stack 
    properties: 
      templateId: "abcdf-fdeee" 
      inputs:
        aaa: {select: [0, {split: [",", {get_input: source}]}]}                 # The value is a.
        bbb: {select: [1, ["alpha", "beta", "gamma"]]}             # The value is beta.