Skip to content
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

Add isnothing() function? #29674

Closed
kescobo opened this issue Oct 16, 2018 · 1 comment
Closed

Add isnothing() function? #29674

kescobo opened this issue Oct 16, 2018 · 1 comment

Comments

@kescobo
Copy link
Contributor

kescobo commented Oct 16, 2018

This came up on slack in the #data channel: it would be nice to have a function to check if something is Nothing, since (apparently) x == nothing has a performance hit, and it's easy to forget to use x === nothing. Related: #28700

More importantly from my perspective, it has a nice symmetry with ismissing() and isnan(). I'm always expecting this to be a thing.

I did some searching in the repo and in discourse, where I found this comment

To simplify checking for nothingness, I wonder whether it’d be helpful to have isnothing (analogous to ismissing), but it’s also true that x isa Nothing isn’t much longer.

The only thing in the repo when I search for "isnothing" is a comment in #414 that uses it in some code (not sure if that was an assumption or if it used to be a thing and isn't anymore).

Working on a simple PR that would add this if there's interest. Basically just

isnothing(x::Any) = x === nothing ? true : false

(plus docs and tests of course 😆)

@kescobo
Copy link
Contributor Author

kescobo commented Oct 20, 2018

Resolved by #29679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant