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

Fix docstrings in nullable.jl #19067

Merged
merged 1 commit into from
Oct 26, 2016
Merged

Fix docstrings in nullable.jl #19067

merged 1 commit into from
Oct 26, 2016

Conversation

xorJane
Copy link
Contributor

@xorJane xorJane commented Oct 23, 2016

This moves inline and edits the docstring for Nullable, adding doctests and changing the function signature. Also fixes the doctests for isnull. Thank you in advance for reviewing :)

"""
Nullable(x, hasvalue::Bool=true)

When `hasvalue` is true, wrap value `x` in an object of type `Nullable`, which indicates
Copy link
Member

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.

Copy link
Contributor Author

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!

@nalimilan nalimilan added missing data Base.missing and related functionality docs This change adds or pertains to documentation labels Oct 23, 2016
@nalimilan
Copy link
Member

Thanks! Looks like I indeed missed these when changing the meaning of the second argument to Nullable.

# Examples

```jldoctest
julia> x = 1; Nullable(x)
Copy link
Member

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?

Copy link
Contributor Author

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))
Copy link
Member

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!

Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tkelman tkelman merged commit 0454007 into JuliaLang:master Oct 26, 2016
fcard pushed a commit to fcard/julia that referenced this pull request Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation missing data Base.missing and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants