Skip to content

Commit

Permalink
Docs for construction of undef arrays with missing type (#31091)
Browse files Browse the repository at this point in the history
The contract is that if `T` is a bits type then creation of uninitialized array of type `Union{Missing, T}` initializes it to hold `missing` in all entries. Mention this in the documentation.
  • Loading branch information
bkamins authored Oct 30, 2020
1 parent 719c4d0 commit f412222
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/src/manual/missing.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ julia> Array{Union{Missing, String}}(missing, 2, 3)
missing missing missing
```

!!! note
Currently for `T` that is bits type (`isbitstype(T)` returns `true`), if `T`
is not a singleton type then `Array{Union{Missing, T}}(undef, dims)` creates
an array filled with `missing` values. Also in this case calling `similar`
to create an unitialized array that has element type of the form
`Union{Missing, T}` creates an array filled with `missing`. If `T` is a
singleton type the value that is used to fill the array is undefined and
could change in the future, so it should not be relied upon.

An array allowing for `missing` values but which does not contain any such value
can be converted back to an array which does not allow for missing values using
[`convert`](@ref). If the array contains `missing` values, a `MethodError` is thrown
Expand Down

0 comments on commit f412222

Please sign in to comment.