将输入变量附加到属性名称
To append the attribute name with an input variable
我想在节点属性名称后附加一个输入整数值。
例如:
count=1
node["example_#{count}"]
期望值:节点[example_1]
但是我们得到的是零值。请告诉我们正确的追加方式。
setting and attribute, and retrieving an attribute之间有差异。
在您分享的代码段中,正在检索节点属性但未分配给任何其他变量。
如果您想为节点属性赋值,请按以下步骤操作:
count = 1
node.default["example_#{count}"] = 'foo'
我想在节点属性名称后附加一个输入整数值。
例如:
count=1
node["example_#{count}"]
期望值:节点[example_1]
但是我们得到的是零值。请告诉我们正确的追加方式。
setting and attribute, and retrieving an attribute之间有差异。
在您分享的代码段中,正在检索节点属性但未分配给任何其他变量。
如果您想为节点属性赋值,请按以下步骤操作:
count = 1
node.default["example_#{count}"] = 'foo'