Open jonthegeek opened 8 months ago
Of course, I'm strongly arguing that the length(x) == 0
version of %||%
is non-sense in particular as I was the one who added %||%
to base only a couple of weeks ago. But even if it was not in base (that R-devel version of base is only due to release next April) many other packages define %||%
, others import it from rlang
... and the "only truly correct" ;-) condition is is.null(.)
..
Yeah, I suspect this came into S7 at a time when the tidyverse team was exploring the length(x) == 0
condition, which we ultimately decided was a bad idea.
My real use-case of this is more complicated, but this is enough to dig into it.
Created on 2023-12-05 with reprex v2.0.2
I traced it to the definition of
%||%
inutils.R
(useslength(x) == 0
, notis.null(x)
; it's more like the unexported%|0|%
from rlang, rather than%||%
).The given default (
factor(levels = c("a", "b"))
) is length 0, but it isn'tNULL
.I'm not sure yet that this actually matters for what I'm doing, but it was surprising (and made me think I had some deeper issue).
I'd try to fix it myself, but I'm getting other errors when I run the tests, and this one seems like it could break things in surprising ways.