condition

Gamma: Version 4.0
Prev |  | Next

# `condition`

`condition` -- tests conditions.

## Syntax

    condition {case condition: statement
               [case condition: statement]
                ...
               [default: statement]}

## Arguments

`condition`

  Any Gamma or Lisp expression.

`statement`

  Any Gamma statement.

## Returns

The return value of the `statement` that corresponds to the first true `condition` or the default. Otherwise nil.

## Description

This statement is similar to the `switch` statement, except that it takes no arguments. It checks the truth value of each `condition` in turn. The first true `condition` encountered returns with the return value of the passed `statement`. If no `condition` is true, it returns the return value of the default `statement`, (or nil, if no default statement is given).

The words "case" and "default" and the symbols {, :, and } are unchanging syntactical elements.

## Example

        Gamma> a = 5;
        5
        Gamma> b = 9;
        9
        Gamma> condition {case a == b: princ("Equal\n"); case a != b: princ("Unequal\n");}
        Unequal
        t
        Gamma>

Also see the example in `switch`.

## See Also

`switch`

Prev | Home | Next
`class` | Up | `for`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.