Switch

Picks one of two values with a condition, evaluating only that one.

Node id logic/switch

The Switch node outputs then when condition is true, and else when it is false: "if … then … else" in a graph.

Inputs

NameTypeDefaultNotes
conditionbooleanfalse
thenT—lazygeneric
elseT—lazygeneric

Outputs

NameTypeNotes
resultTgeneric

Behaviour

  • Only the chosen branch is evaluated. then and else are lazy inputs: the nodes feeding the branch that isn't picked don't run at all. A failing node there doesn't make Switch fail, and a heavy one costs nothing.
  • Any type. then, else and result are generic pins of the same type: the first wire connected to one of them sets it for all three. Connect two circles, two numbers, two arrays…
  • condition is false by default. Connect a comparison (Greater, Equals Number…) or set it in the property inspector.
  • Inside a function, the condition can differ for every call: in a Map function, for example, each element can take its own branch. A subgraph call in the branch that isn't picked is not made.
  • The base case of a recursion. In a subgraph that calls itself, a Switch decides when to stop: the base case in then, the calls in else. See Recursion and the Sierpinski triangle.

Errors

  • The chosen branch must be connected: being generic, then and else can't be set in the property inspector. "Switch: nothing connected to then" (or else) names the missing one. The other branch may stay unconnected.
  • If a node of the chosen branch fails, Switch fails too and its branch is left out. The failing node is the one marked.
  • And and Or: the other nodes that skip inputs they don't need.
  • Filter: keeps the elements of an array that pass a test.
  • Repeat: runs a function until a condition stops it.
© 2026 Wirepaint