Replies: 2 comments 2 replies
-
The cases I know of are when the tested value need not be a boolean at all. Try these:
I think there are also cases of empty logical vecotrs.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Ok thanks, so the verification of isTRUE and isFALSE is broader but is it
needed. It is mainly used on the `$is_disabled()` method of `FilterState`.
Do you think it is possible that this method returns anything else besides
TRUE of FALSE?
…On Fri, May 26, 2023 at 2:39 PM Aleksander Chlebowski < ***@***.***> wrote:
The cases I know of are when the tested value need not be a boolean at
all. Try these:
x <- NULL
if (x) print("ok") else print("not ok")
x <- all.equal(letters[1:4], letters[4:1])
if (x) print("ok") else print("not ok")
I think there are also cases of empty logical vecotrs.
if (logical(0)) print("ok") else print("not ok")
—
Reply to this email directly, view it on GitHub
<#303 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A74AIEK4IFO2AYCMCZFVFZLXICP7RANCNFSM6AAAAAAYQEQADM>
.
You are receiving this because you authored the thread.Message ID:
<insightsengineering/teal.slice/repo-discussions/303/comments/6011375@
github.com>
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, I'm new in the project and in the code and some conventions are not year clear for me. I allowed myself to open this small discussion, where everybody can express their opinion or replies offline/asynchronously (in their own time, on their own pace). This is not a big deal so do not feel you are obliged to provide any complex and broad explanations - do not even feel obliged to participate at all. Reply only if you think it's worth it.
I wanted to discuss the topic of the usage of
isFALSE()
andisTRUE
withinteal.slice
code against the typical usage of!
and lack of it for the verification of logical flag statuses.Imagine the below code
in which
== TRUE
is redundant, as the same can be achieved withand it's faster and uses less space. There is one more function to detect logical values which is
isTRUE()
andisFALSE()
that you could use in this situationwhich seems as overcomplicated and as unnecessary as
== TRUE
.Is there any specific reason we use
isTRUE()
andisFALSE()
within the code besides it's a bit more than justidentical(x, TRUE)
.It is actually
is.logical(x) && length(x) == 1 && !is.na(x) && x
.Is this needed because of the shiny or specific states of elements of our classes?
Happy to hear the reasoning, as perhaps there is any. Eager to get it in writing for future newcomers as well as a small reference on a design decisions.
Beta Was this translation helpful? Give feedback.
All reactions