Операторы сравнения
Prev | Chapter 6. Программирование в GEL | Next

## Операторы сравнения

В GEL поддерживаются следующие стандартные операторы сравнения, имеющие очевидное значение: `==`, `>=`, `<=`, `!=`, `<>`, `<`, `>`. Они возвращают `true` или `false`. Операторы `!=` и `<>` эквивалентны и означают «не равно». GEL также поддерживает оператор `<=>`, который возвращает -1, если левая сторона меньше, 0 при равенстве обеих сторон и 1, если левая сторона больше.

Normally `=` is translated to `==` if it happens to be somewhere where GEL is expecting a condition such as in the if condition. For example

    if a=b then c
    if a==b then c

are the same thing in GEL. However you should really use `==` or `:=` when you want to compare or assign respectively if you want your code to be easy to read and to avoid mistakes.

All the comparison operators (except for the `<=>` operator, which behaves normally), are not strictly binary operators, they can in fact be grouped in the normal mathematical way, e.g.: (`1<x<=y<5`) is a legal boolean expression and means just what it should, that is (1<x and x≤y and y<5)

To build up logical expressions use the words `not`, `and`, `or`, `xor`. The operators `or` and `and` are special beasts as they evaluate their arguments one by one, so the usual trick for conditional evaluation works here as well. For example, `1 or a=1` will not set `a=1` since the first argument was true.

Prev | Up | Next
Суммы и произведения | Home | Глобальные переменные и область видимости переменных