Page MenuHomeFeedback Tracker

[Improve] make the '==' operator accept bool values
New, WishlistPublic

Description

Its very confusing that the '==' operator is not accepting bool values for new scripters (until they see the reference for it which they may dont do because they think its default behaviour)

also its just a logical thing because arma has bool values but is not able to compare two of them in one of the most common ways ('&&' is also a logic way to do but it is used to link two compares so it should not be used to compare booleans)

so please add the boolean type to the compare operator of SQF

additional info on the ==

totally forgot to add to this that comparing bool values using && is not rly comparing at all! Its logical math and nothing else!

BOOL1 == BOOL2 would be comparing which is simple and easy

to compare a bool in SQF you need to do it like the following example:
(BOOL1 && BOOL2 || !BOOL1 && !BOOL2)

it takes much longer in total as more commands are used then a usual compare would be

Details

Legacy ID
2205397685
Severity
None
Resolution
Open
Reproducibility
N/A
Category
Scripting

Event Timeline

X39 edited Steps To Reproduce. (Show Details)Nov 11 2013, 9:45 PM
X39 edited Additional Information. (Show Details)
X39 set Category to Scripting.
X39 set Reproducibility to N/A.
X39 set Severity to None.
X39 set Resolution to Open.
X39 set Legacy ID to 2205397685.May 7 2016, 5:23 PM

Edit: I see what you mean, yeah could be awkward for beginners

X39 added a subscriber: X39.May 7 2016, 5:23 PM
X39 added a comment.Nov 12 2013, 1:11 AM

^^ there is also a overview problem if you need to compare boolean values and after that integers and so on
which looks like so:
((_boola && _boolb) && (_inta == _intb))

i'll be the first to admit i still try bool==bool with odd regularity, despite knowing better :) but it doesn't bother me that i can't use ==, less typing anyways!

As it stands currently it kinda makes sense: a bool is the answer to its own expression. theres no point in comparing true == true, when true is already the result.

But I'll /upvote for behavior predictability

using
(a == b)
you don't need to know if
a = true;
b = true;
or
a = false;
b = false;
using
(a && b)
will not work for second example where you have to know if both are false then use
(!a && !b)

EDIT: awkward

X39 added a comment.Jan 1 2014, 3:07 PM

still not even a review?
also
i would like to know why people downvote
because it just makes sense to compare two booleans for equalness (instead of value)
see the example above
because
when you got this case:
_b1 = false;
_b2 = false;
and compare both with &&
you need to do two compares for a single "is equal" check!
(_b1 && _b2) || (!_b1 && !_b2)

X39 added a comment.May 8 2014, 12:24 AM

another bump because of importance!

The new command isEqualTo takes booleans

X39 added a comment.May 8 2014, 2:27 AM

it should not be the solution to use isEqualTo instead of ==

From what I understood after talking to programmer is that what you are asking is not going to happen. Even introducing === for strict comparison to be able to compare booleans was out of the question. And for sure no one will even think of altering behaviour of ==. Of course feel free to bump this till the world's end, but If I were you I'd take isEqualTo.