(arguments: {branches: {if: boolean, then: any}[], default: any}): anyThe _switch operator evaluates an array of conditions and returns the then argument of the first item for which the if argument evaluates to true. If no condition evaluates to true, the value of the default argument is returned.
Arguments
object
branches:if: boolean: The boolean result of a test.then: any: The value to return if the test istrue.default: any: The value to return if all theiftests arefalse.
Examples
Return a value based on a series of conditions:
_switch:
branches:
- if:
_eq:
- x
- y
then: A
- if:
_eq:
- x
- z
then: B
default: CReturns: "C" since both of the if tests are false.
