Les opérateurs de comparaison standard suivants sont pris en charge dans GEL et ont des significations évidentes : ==
, >=
, <=
, !=
, <>
, <
, >
. Ils renvoient true
ou false
. Les opérateurs !=
et <>
sont les mêmes et signifient « n'est pas égal à ». GEL comprend également l'opérateur <=>
qui renvoie -1 si la partie de gauche est plus petite, 0 si les deux parties sont égales, 1 si la partie de gauche est plus grande.
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)
Pour construire des expressions logiques, utilisez les mots not
, and
, or
, xor
. Les opérateurs or
et and
sont des entités spéciales car ils évaluent leurs arguments les uns après les autres, donc les astuces classiques des évaluations conditionnelles fonctionnent. Par exemple : 1 or a=1
n'effectue pas l'attribution a=1
puisque le premier argument est vrai (true).