Leonardus
Loading...
Searching...
No Matches
Figurative LeoScript Operator switch

STACK

$ D\ X\ -- $

DESCRIPTION

The switch operator uses X as a key to look up a value in dictionary D.

  • If X is found, its associated value is executed.
  • If X is not found but D has a null key, the value of the null key is executed.
  • If neither X nor a null key exists in D, the operator does nothing.

Key comparisons use the eq operator, so keys must be primitive (non-composite) objects. Values in D can be of any type (e.g., procedures, numbers, or arrays), and will be executed or returned accordingly.

ORIGIN

Procedure from boot.leo registered in systemdict.