MCPcopy
hub / github.com/hashicorp/hcl / ForExpr

Struct ForExpr

hclsyntax/expression.go:1375–1390  ·  view source on GitHub ↗

ForExpr represents iteration constructs: tuple = [for i, v in list: upper(v) if i > 2] object = {for k, v in map: k => upper(v)} object_of_tuples = {for v in list: v.key: v...}

Source from the content-addressed store, hash-verified

1373// object = {for k, v in map: k => upper(v)}
1374// object_of_tuples = {for v in list: v.key: v...}
1375type ForExpr struct {
1376 KeyVar string // empty if ignoring the key
1377 ValVar string
1378
1379 CollExpr Expression
1380
1381 KeyExpr Expression // nil when producing a tuple
1382 ValExpr Expression
1383 CondExpr Expression // null if no "if" clause is present
1384
1385 Group bool // set if the ellipsis is used on the value in an object for
1386
1387 SrcRange hcl.Range
1388 OpenRange hcl.Range
1389 CloseRange hcl.Range
1390}
1391
1392func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
1393 var diags hcl.Diagnostics

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected