Lazy Switch¶
Selects between two inputs based on a boolean switch, returning on_true when switch is True and on_false when False. Uses lazy evaluation so only the selected branch is evaluated and requested, helping avoid unnecessary computation.

Usage¶
Use this node to route data conditionally in a workflow. Connect a boolean decision to switch, and provide two alternative inputs for on_true and on_false. Only the chosen input is fetched/evaluated, making it ideal for expensive or optional branches.
Inputs¶
| Field | Required | Type | Description | Example | 
|---|---|---|---|---|
| switch | True | BOOLEAN | Boolean control that determines which input to return. True selects on_true, False selects on_false. | True | 
| on_false | True | WILDCARD | Value to output when switch is False. Marked as lazy; it will not be evaluated unless needed. | Any compatible data type (e.g., an image tensor, text, number) | 
| on_true | True | WILDCARD | Value to output when switch is True. Marked as lazy; it will not be evaluated unless needed. | Any compatible data type (e.g., an image tensor, text, number) | 
Outputs¶
| Field | Type | Description | Example | 
|---|---|---|---|
| value | WILDCARD | The selected value from on_true or on_false based on the switch. | The same type as the chosen input | 
Important Notes¶
- Both on_true and on_false should be of compatible types since the output type follows the selected input.
- Lazy evaluation means only the branch indicated by switch is requested and computed. The other branch can be unconnected or expensive without overhead.
- If an internal error occurs, the node may output a null/empty value. Ensure inputs are valid and available when selected.
Troubleshooting¶
- Selected branch has no connection: If switch selects an unconnected input, the output will be empty/null. Connect the corresponding input or ensure the switch condition avoids it.
- Type mismatch downstream: Ensure consumers of value can handle the data type emitted by the selected branch.
- Unexpected computation on both branches: Verify you are not forcing both branches elsewhere; this node is lazy and only requests the selected input.