Package: org.codehaus.groovy.ast.stmt

## [Java] Class YieldStatement

- org.codehaus.groovy.ast.stmt.YieldStatement

-     public class YieldStatement
      extends Statement

  Represents a `yield` statement that produces the value of an enclosing SwitchExpression. Unlike ReturnStatement, `yield` does not return from the enclosing method; it completes the switch expression and transfers the yielded value to the expression's join point (JEP 361).

  See Also:
    SwitchExpression
    ReturnStatement
  Since:
    6.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `YieldStatement(Expression expression)` Constructs a yield statement with the given result expression.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Expression` | `getExpression()` Returns the expression whose value becomes the switch-expression result.
    `` | `public String` | `getText()`
    `` | `public void` | `setExpression(Expression expression)` Sets the expression whose value becomes the switch-expression result.
    `` | `public String` | `toString()`
    `` | `public void` | `visit(GroovyCodeVisitor visitor)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Statement` | `addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabel`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### public YieldStatement(Expression expression)

      Constructs a yield statement with the given result expression.

      Parameters:
        `expression` - the value produced for the enclosing switch expression

  - ### Method Detail

    - #### public Expression getExpression()

      Returns the expression whose value becomes the switch-expression result.

      Returns:
        the yielded Expression

    - #### public String getText()

    - #### public void setExpression(Expression expression)

      Sets the expression whose value becomes the switch-expression result.

      Parameters:
        `expression` - the yielded Expression

    - #### public String toString()

    - #### public void visit(GroovyCodeVisitor visitor)