Predicate

From Director Online Wiki
Jump to: navigation, search

In general computing terms a predicate function is a function that returns either true or false and does not perform any action. In essence, you use predicates to find the answer to a simple question that can have only a yes or no answer, e.g., "isTheGameRunning()".

Lingo has a set of predicate functions that are used to determine the type of a particular variable. The Lingo predicate functions are as follows:

  • floatP - Does the variable contain a floating point value?
  • integerP - Does the variable contain an integer value?
  • listP - Does the variable point to a list object?
  • objectP - Does the variable contain an object?
  • stringP - Does the variable contain a string value?
  • symbolP - Does the variable contain a symbol?
  • voidP - Does the variable contain VOID?

Note that for greater flexiblilty, it is often better to use the ilk function instead of the predicates. The predicates do tend to make for more readable code though, particularly for very common tests like voidP.

See Also

ilk