-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix docstrings in nullable.jl #19067
Conversation
""" | ||
Nullable(x, hasvalue::Bool=true) | ||
|
||
When `hasvalue` is true, wrap value `x` in an object of type `Nullable`, which indicates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would phrase it slightly differently: as the original docstring said (even though it was incomplete), x
is always wrapped in the resulting Nullable
. The hasvalue
argument will determine whether the value will be considered present or not, but it's actually always there in the value
field of the result (cf. #16923).
The hasvalue
argument is useful only in quite specific cases, so I'd mention it only in a separate paragraph, to keep the explanation for the one-argument form simple. The fist paragraph could almost be kept as it is currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would phrase it slightly differently: as the original docstring said (even though it was incomplete), x is always wrapped in the resulting Nullable. The hasvalue argument will determine whether the value will be considered present or not, but it's actually always there in the value field of the result (cf. #16923).
I appreciate the explanation and reference. I understand the behavior better now.
The hasvalue argument is useful only in quite specific cases, so I'd mention it only in a separate paragraph, to keep the explanation for the one-argument form simple. The fist paragraph could almost be kept as it is currently.
Now the hasvalue
argument is addressed in the second paragraph of the docstring only. I've included an additional doctest to better illustrate behavior when hasvalue
is false
.
Thanks!
Thanks! Looks like I indeed missed these when changing the meaning of the second argument to |
# Examples | ||
|
||
```jldoctest | ||
julia> x = 1; Nullable(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not replace x
with 1
directly in the expressions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Fixed it!
julia> Nullable(x, false) | ||
Nullable{Int64}() | ||
|
||
julia> dump(Nullable(x, false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to show this indeed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This moves inline and edits the docstring for
Nullable
, adding doctests and changing the function signature. Also fixes the doctests forisnull
. Thank you in advance for reviewing :)