If Else Op

This operation runs if and returns evaluated true expression or evaluated false expression.

Definition: ["ifElse", <check: expression(boolean)>, <trueResult: expression(any)>, <falseResult: expression(any)>]

  • <check: expression(boolean)> - represents an expression which returns truthy or falsy value.
  • <trueResult: expression(any)> - Expression which is evaluated and returned if the result from check is truthy.
  • <falseResult: expression(any)> - Expression which is evaluated and returned if the result from check is falsy.

Usage

Request:

["ifElse", ["value", true], ["value", "true value"], ["value", "false value"]]

Response:

"true value"

Typical Usage

This operation is used when one or the other expression needs to evaluated and returned based on some check.

Example:

Request:

["ifElse", 
  ["run", "userExists", 1], 
  ["value", "There is an user with ID 1"], 
  ["value", "No user found."] 
]

Response:

"There is an user with ID 1"