[Gambas-user] Short-circuit evaluation question

Gianluigi bagonergi at gmail.com
Fri Jan 26 18:01:39 CET 2018


Hi Tobias,
kind and accurate in explanations, as always :-)

Thank you very much

Regards
Gianluigi

2018-01-26 17:18 GMT+01:00 Tobias Boege <taboege at gmail.com>:

> On Fri, 26 Jan 2018, Gianluigi wrote:
> > Hi Charlie,
> > apologize me for the project and the question, all very confusing.
> >
> > The question was on the short circuit.
> > The NULL array is intended to demonstrate that short cirquitation does
> not
> > work in the second IF block.
> > I think it's due to the fact that the second IF starts with NOT.
> > See the new attached project
> > Thank you very much for your reply
> >
>
> Short circuit evaluation works, but your code in the second case
>
>   Dim ss As String[]
>   If Not IsNull(ss) Or If ss.Count > 0 Then
>
> requires a long circuit. ss *is* Null here, so "Not IsNull(ss)" will
> be false, requiring the second condition to be evaluated, which gives
> you an error.
>
> As a general rule, whenever
>
>   If Condition1 Or If Condition2
>
> takes a short-circuit,
>
>   If Not Condition1 Or If Condition3
>
> will require a long one.
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> --------------------------------------------------
>
> This is the Gambas Mailing List
> https://lists.gambas-basic.org/listinfo/user
>
> Hosted by https://www.hostsharing.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180126/0ab3842e/attachment.html>


More information about the User mailing list