[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: short circuit & and | in if and while
From: |
Mike Miller |
Subject: |
Re: short circuit & and | in if and while |
Date: |
Wed, 13 Sep 2017 17:22:50 -0700 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
On Thu, Sep 14, 2017 at 02:15:16 +0200, Ernst Reissner wrote:
> Is there anyone who can explain me,
>
> why in matlab, and thus in octave,
>
> if(a&b) is interpreted like if(a&&b),
>
> whereas c=a&b differs from c=a&&b
>
> which means that
>
> if(a&b) is not the same as c=a&b;if(c)...
>
> Very strange.
>
> This feature also applies to while but not to until...
>
> Who can explain me???
Here is an official answer from Mathworks Support that describes the
behavior
https://www.mathworks.com/matlabcentral/answers/99518-is-the-logical-operator-in-matlab-a-short-circuit-operator
This is a "what", not a "why". I don't know who you can ask for an
answer to "why", it just is.
--
mike
signature.asc
Description: PGP signature