-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow map_*() to consult .null for length 0 elements #254
Comments
Should this be another argument |
At least when JSON is the source of the list, it seems morally ok to handle via |
otoh It's true that we already conflate void elements with NULL values, but that's mainly because void elements are generally treated as |
I see your point. But once you've committed to making an atomic vector of a certain type, I would guess that void, NULL, and empty almost always become |
Related to #199 |
This feels wrong to me, conflating the notions of null and empty. Empty is a property of vectors, while null is a property of any R object (which are all option types thanks to null). We have the same problem in rlang. It would still be useful to have a term that means "either NULL or empty". Maybe lengthless, since |
To be more precise, I don't think it's a bad idea to treat NULLs and empty the same way, I do it all the time by checking the length, e.g. |
We were partially doing this anyway and it makes life easier; but maybe we should change |
yes I now see the rlang definition for |
Yeah. I sometimes think of NULL as an object is a vector with no type but length 0. |
You could attack this from another angle and name the argument |
In fact, dplyr seems to have a function for this: |
Another option would be |
I like |
It's baaack. See #231 and #110. When
map_*()
is used for indexing, we can now use.null
to specify a value if the key is missing or has explicit value ofNULL
. But now I am struggling with the case where the element is present, is notNULL
, but has length zero.I have real examples of this phenomenon from the GitHub API.
cc @jeremystan
The text was updated successfully, but these errors were encountered: