• Returns an expression that can be used to chain multiple when-then statements together. On the returned case expression, you can add cases by calling when with an expression and subsequently call then with another expression. This creates a chain of if-then-else statements. If no cases match, the result of the default expression is used. The expression given as argument to a when-call should result in boolean.

    var defaultExpression = ...;
    var someTestExpression = ...;
    var someResultExpression = ...;
    var someOtherTestExpression = ...;
    var someOtherResultExpression = ...;

    var caseExpression = ExpressionFactory.cases(defaultExpression);
    caseExpression.when(someTestExpression).then(someResultExpression)
    .when(someOtherTestExpression).then(someOtherResultExpression);

    Type Parameters

    • T extends string | number | Vector3

    Parameters

    • defaultExpression: Expression<T>

      The expression evaluated if no when-then case is met.

    Returns CaseExpression<T>

    A case expression that can be used to add when-then cases.