help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Evaluating 'or' statements: bug or feature?


From: Bill Denney
Subject: Re: Evaluating 'or' statements: bug or feature?
Date: Tue, 08 Jul 2008 20:20:08 -0400
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Andy Sinton wrote:
I've encountered this issue twice when running .m files in Octave
(3.01, windows).
With an 'or' statement such as

if u > v | someFunction(b)

chokes if there is no variable 'b', even though it is true that u > v.
 I guess Matlab stops evaluating 'or' statements when it hits the
first true statement and Octave keeps going?
Is there a reason for this bug/feature?
Thanks!

Hi Andy,

This is a topic that comes up relatively often. The short answer is that if you want a shortcutting or, you need to use the double pipe (||). The single pipe is an element-wise or while double is a boolean or. Assuming that u, v, and the output of someFunction(b) are all scalars, you are probably wanting

u > v || someFunction(b)

Have a good day,

Bill


reply via email to

[Prev in Thread] Current Thread [Next in Thread]