From f41222212c880d396728a292da413d1b87622560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Fri, 30 Oct 2020 15:48:58 +0100 Subject: [PATCH] Docs for construction of undef arrays with missing type (#31091) 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. --- doc/src/manual/missing.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/src/manual/missing.md b/doc/src/manual/missing.md index 57ebb37952a62..4878636ff1587 100644 --- a/doc/src/manual/missing.md +++ b/doc/src/manual/missing.md @@ -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