Gambas-it

Gambas dal mondo esterno => Mailing List => Topic aperto da: vuott - 06 Ottobre 2014, 01:25:28

Titolo: Usare AND ed OR nello stesso test logico
Inserito da: vuott - 06 Ottobre 2014, 01:25:28
Vi riporto questa discussione:


" Why is it not allowed to use AND and OR in the same logical test?

Jørn
"


" It is allowed and works:

  $ gbx3 -e "(False And Not False) Or (False Or Not False)"
  True

Maybe you refer to the AND IF and OR IF keywords in an IF statement?

Regards,
Tobi
"


" Aha, yes you're right :) Removing an extra IF that had sneaked in was
the solution.

Jørn
"


" The extra "if" enables short-circuiting
http://en.wikipedia.org/wiki/Short-circuit_evaluation
and thus it is very useful in some cases.

Example, you can write "if then" structures like this:

Codice: gambas [Seleziona]
If hObject <> Null And If hObject.SomeProperty = True Then


Without the extra "if" this would fail, if the hObject would be null.

Jussi
"