This function allows you to create in FlexQuery expressions a construct similar to switch statement in Java. On a large number of cases, it may work substantially faster than running through the equivalent number of consecutive conditional statements. For example:

switch (
  val,  // the value to match to switch cases
  SwitchCase[] ( // create an array of cases
    SwitchCase ( // create 1-st case
      'A', // the matching value, which 
           // triggers that case
      1    // the result to be returned in that
           // case by switch() function
    ),
    SwitchCase ( // create 2-nd case
      'B', // the matching value

      // instead of a single value, specify
      // for that case a subquery to evaluate
      FlexQuery ({
        ... // do something here

        2 // the result to be returned by switch()
      })
    ),
    SwitchCase ( // create 3-rd case
      // it matches several values at once
      // specified in an array
      Array ('C', 'D', 'E'),
      // a subquery to evaluate in that case
      FlexQuery ({
        ... // do something here

        val // the result to be returned:
            // the same value as passed
            // to the switch()
      })
    )
  ),
  // the default subquery: executed
  // when none of the cases matched
  FlexQuery ({
    ... // do something here

    -1  // the result to be returned by switch()
  })
);
Parameter:

value

The value to match to switch cases so as to trigger the processing of one of them.
cases
A typed array of SwitchCase objects representing each switch case.

Such an array can be created only with a function-call-like construct looking as follows

SwitchCase[] (
  ...
)
where the array items must be objects created using SwitchCase() function and listed inside the round brackets separated with commas.
defaultQuery
Specify the subquery that is executed when no matching case has been found.

The subquery must be created using FlexQuery() function. The result returned by the subquery will be the function's result.

When this parameter is omitted or null and no matching case has been found, the function does nothing and returns null.

Returns:
The value specified as the result one in the matching case or returned by the result subquery alternatively specified in it. When no cases match, that will be the result returned by the default subquery or null if none specified.
See Also:
SwitchCase(), FlexQuery()