[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #63515] logical should convert char and string
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #63515] logical should convert char and strings instead of throwing an error for Matlab compatibility |
Date: |
Tue, 13 Dec 2022 09:18:39 -0500 (EST) |
Follow-up Comment #2, bug #63515 (project octave):
thanks, that matches matlab behavior for other logical uses of chars and
strings, except for the short circuit operators as was discussed over at
https://octave.discourse.group/t/logical-tests-with-char-vectors/3581/22
>> if ('chars'), disp('hello'),end
hello
>> if ("str"), disp('hello'),end
Conversion to logical from string is not possible.
>> true & 'chars'
ans =
1×5 logical array
1 1 1 1 1
>> true & "str"
Operator '&' is not supported for operands of type 'string'.
>> true && 'chars'
Operands to the logical AND (&&) and OR (||) operators must be convertible to
logical scalar
values. Use the ANY or ALL functions to reduce operands to logical scalar
values.
>> true && "str"
Conversion to logical from string is not possible
so, whether or not this would get addressed before Octave has a working string
object, Octave would have to decide what the desired output is. I would argue
that octave should allow conversion in all cases, initially no difference
between 'str' and "str", and later after implementation the only difference
being that logical('str') turns into [true true true], while logical("str")
would turn into [true].
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63515>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/