Switch constructor

Switch(
  1. {required List<Case> branches,
  2. dynamic defaultExpr}
)

Creates $switch operator expression

  • branches - An array of control branch object. Each branch is an instance of Case
  • defaultExpr - Optional. The path to take if no branch case expression evaluates to true. Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error.

Implementation

Switch({required List<Case> branches, defaultExpr})
    : super(
          'switch',
          AEObject({
            'branches': AEList(branches),
            if (defaultExpr != null) 'default': defaultExpr
          }));