warning: suggest parenthesis around assignment used as truth value

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

warning: suggest parenthesis around assignment used as truth value

José Abílio Matos
I am using octave 6 and I am getting this dreadful :-):

warning: suggest parenthesis around assignment used as truth value near line
135...

The line where it complains is the one after the elseif:

if length(rhs) < pow || isempty(rhs{pow})
    rhs{pow} = terms{j}(start:end);
elseif
    rhs{pow} = [rhs{pow}, ' + ', terms{j}(start:end)];
end


In terms of context we have that "terms" is a cell string (in column mode) and
"rhs" is also a cell string.


Searching I found this previous thread:
https://lists.gnu.org/archive/html/octave-maintainers/2009-03/msg00289.html


I am reporting this because I was surprised by the warning and I fail to see
where is this relevant.

Thank you,
--
José Matos



Reply | Threaded
Open this post in threaded view
|

Re: warning: suggest parenthesis around assignment used as truth value

Ian McCallion
On Tue, 17 Mar 2020 at 10:44, José Abílio Matos <[hidden email]> wrote:

>
> I am using octave 6 and I am getting this dreadful :-):
>
> warning: suggest parenthesis around assignment used as truth value near line
> 135...
>
> The line where it complains is the one after the elseif:
>
> if length(rhs) < pow || isempty(rhs{pow})
>     rhs{pow} = terms{j}(start:end);
> elseif
>     rhs{pow} = [rhs{pow}, ' + ', terms{j}(start:end)];
> end

Replace elseif with else. Octave is taking "rhs{pow} =
terms{j}(start:end);" as a condition

Cheers... Ian

Reply | Threaded
Open this post in threaded view
|

Re: warning: suggest parenthesis around assignment used as truth value

José Abílio Matos
On Tuesday, 17 March 2020 11.12.32 WET Ian McCallion wrote:
> Replace elseif with else. Octave is taking "rhs{pow} =
> terms{j}(start:end);" as a condition
>
> Cheers... Ian

Thank you Ian. That makes sense.

At the time I was writing the code I had another condition that I had since
condensed and forgot the elseif.

Regards,
--
José Matos