Documentation Language: Swift

Structure

MTLForStatement

A for loop statement for iterating over collections.

struct MTLForStatement

Overview

For statements provide iteration capabilities in MTL templates, allowing generation of repeated content with optional separators.

Example Usage

let itemVar = MTLVariable(name: "item", type: "Element")
let collectionExpr = MTLExpression(AQLVariableExpression(name: "items"))
let binding = MTLBinding(variable: itemVar, initExpression: collectionExpr)
let separator = MTLExpression(AQLLiteralExpression(value: ", "))

let forStmt = MTLForStatement(
    binding: binding,
    separator: separator,
    body: MTLBlock(statements: [
        MTLExpressionStatement(expression: MTLExpression(AQLVariableExpression(name: "item")))
    ])
)

Topics

Initializers

?
init(binding:separator:body:multiLines:)

Creates a new for statement.

Instance Properties

V
binding

The variable binding for the loop.

V
body

The block of statements to execute for each iteration.

V
multiLines

Whether this statement spans multiple lines.

V
separator

Optional expression to evaluate and output between iterations.

Instance Methods

F
execute(in:)

Executes the statement within the specified execution context.

Default Implementations

Relationships

Conforms To