> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metrics-man.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Return

# \$return

The `$return` operator returns a value from the current execution context, typically used for early exits from blocks.

## Input

* An optional single value to return (if omitted, returns null)

## Output

* The specified value, which causes an early exit from the containing block

## Examples

### Return Specific Value

```json theme={null}
{
  "$block": [
    {
      "$let": [
        "x",
        10
      ]
    },
    {
      "$ifelse": [
        {
          "$gt": [
            {
              "$var": ["x"]
            },
            5
          ]
        },
        {
          "$return": [
            "x is greater than 5"
          ]
        },
        "x is not greater than 5"
      ]
    },
    "This will not be executed if x > 5"
  ]
}
```

Result: `"x is greater than 5"` if x is greater than 5

### Return Without Value

```json theme={null}
{
  "$block": [
    {
      "$return": []
    },
    "This will not be executed"
  ]
}
```

Result: `null`

### Return Field Value

```json theme={null}
{
  "$block": [
    {
      "$ifelse": [
        {
          "$eq": [
            {
              "$input": "status"
            },
            "error"
          ]
        },
        {
          "$return": [
            {
              "$input": "error_message"
            }
          ]
        },
        {
          "$input": "result"
        }
      ]
    }
  ]
}
```

Result: The error\_message field if status is "error", otherwise the result field
