The question mark-colon (?:) is a symbol for the Safe Navigation Operator. It supports the conditional execution of a chain of object-oriented ABL cascading element references. The ? in the symbol indicates conditional execution. The Safe Navigation Operator provides the ability to write crisp, object-oriented ABL code that is the equivalent of an elaborate IF ...THEN...ELSE block.

Syntax

{object-reference}?:{class-member-name}.
Object-reference
Reference to an instance of an ABL class that defines the specific data member as an instance member (non-static).
class-member-name
The name of a data member or member method you want to access. A class member is an element that is defined in and at the level of a class definition.

The following rules apply when using the safe navigation operator:

  • White space is not permitted between the question mark and the colon punctuation of the Safe Navigation Operator (?:). If present, the AVM terminates the compilation and throws a syntax error.
  • The Safe Navigation Operator cannot be used on the left-hand side of an assignment expression.
  • The Safe Navigation Operator can only be used with object-oriented ABL objects. It is not available for use with non object-oriented ABL built-in widgets.
  • Upon finding the Safe Navigation Operator, the AVM tests if the object on the left-hand side of the operator is valid before de-referencing the object on the right-hand side of the operator. If the object on the left-hand side of the operator is invalid, the AVM stops further de-referencing of chained methods and returns the Unknown (?) value.
  • The Safe Navigation Operator performs a short-circuit evaluation of chained elements. It stops the execution of the chain as soon as it discovers an invalid object reference and returns the Unknown (?) value.
  • To check if the expression is executed successfully use the following expression:
    If return-value is ? then do <something>.

See also

: Punctuation