-
-
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
additional convert methods for Nullable #9351
Conversation
I think the first definition is fine, but a non-null value should not be silently converted to null. We should use a constant |
The I think your changes are justified disregarding that debate (one should be able to convert |
Before merging we should probably also add some tests for the new methods. |
@ivarne sure. Since Also, another issue of minor confusion is that since the documentation says that |
I don't think there's a contradiction there: you can have immutable containers. Julia doesn't have enough of them yet, but they are useful. Nullable happens to be one of the first examples of a Julian immutable container, aside from tuples. Quoting what I said on the mailing list:
|
I would be less unhappy supporting function mean(x::Array{Nullable{Float64}})
s, n = 0.0, length(x)
for i in 1:n
if isnull(x[i])
return NULL
else
s += get(x[i])
end
end
return Nullable(s / n)
end |
Union types have a really bad rap, but inference of |
OK. I have changed this PR to only include the first method. Will merge this is a short while since we more or less have consensus on this. Will open a new issue to generate consensus on a less verbose way of making a Nullable field null. |
additional convert method for Nullable
Allows for :
EDIT: The PR has been updated to only support assignment of a non-null value to a Nullable field. See discussion below.