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

Make Some example in something docstring more informative #47682

Merged
merged 4 commits into from
Nov 28, 2022

Conversation

halleysfifthinc
Copy link
Contributor

Previous example:

julia> something(Some(1), nothing)
1

PR example:

julia> typeof(something(nothing, Some(nothing)))
Nothing

The previous example this PR replaces was a potentially confusing and nonsensical use of Some with something.

(AFAIU from the docs), The sole purpose of Some is to distinguish a non-value nothing from a value nothing (presumably with the use of something). Therefore, a literal Some(1) is not an informative example, since an unwrapped 1 would also be returned by something (i.e. the Some wrapper in that example does not change the result).

The new example is a clearer way of showing how something and Some interact.

@brenhinkeller brenhinkeller added the docs This change adds or pertains to documentation label Nov 23, 2022
@mcabbott
Copy link
Contributor

Maybe both should be there, since you can unwrap other values?

Also, perhaps it ought to read something(Some(nothing), 2) === nothing, so that there is only one place the nothing could have come from (and to drop one set of nesting).

base/some.jl Outdated Show resolved Hide resolved
base/some.jl Outdated Show resolved Hide resolved
@fredrikekre fredrikekre added the merge me PR is reviewed. Merge when all tests are passing label Nov 28, 2022
@fredrikekre fredrikekre merged commit 1badb9d into JuliaLang:master Nov 28, 2022
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Dec 5, 2022
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants