Skip to content

Commit

Permalink
Fix manual about propagation of missing values (JuliaLang#35264)
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan authored and oxinabox committed Apr 8, 2020
1 parent bef413f commit ea9c614
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions doc/src/manual/missing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ and behaves like them in most situations.

## Propagation of Missing Values

The behavior of `missing` values follows one basic rule: `missing`
values *propagate* automatically when passed to standard operators and functions,
in particular mathematical functions. Uncertainty about the value of one of the operands
induces uncertainty about the result. In practice, this means an operation involving
a `missing` value generally returns `missing`
`missing` values *propagate* automatically when passed to standard mathematical
operators and functions.
For these functions, uncertainty about the value of one of the operands
induces uncertainty about the result. In practice, this means a math operation
involving a `missing` value generally returns `missing`
```jldoctest
julia> missing + 1
missing
Expand All @@ -31,12 +31,17 @@ As `missing` is a normal Julia object, this propagation rule only works
for functions which have opted in to implement this behavior. This can be
achieved either via a specific method defined for arguments of type `Missing`,
or simply by accepting arguments of this type, and passing them to functions
which propagate them (like standard operators). Packages should consider
which propagate them (like standard math operators). Packages should consider
whether it makes sense to propagate missing values when defining new functions,
and define methods appropriately if that is the case. Passing a `missing` value
to a function for which no method accepting arguments of type `Missing` is defined
throws a [`MethodError`](@ref), just like for any other type.

Functions that do not propagate `missing` values can be made to do so by wrapping
them in the `passmissing` function provided by the
[Missings.jl](https://github.com/JuliaData/Missings.jl) package.
For example, `f(x)` becomes `passmissing(f)(x)`.

## Equality and Comparison Operators

Standard equality and comparison operators follow the propagation rule presented
Expand Down

0 comments on commit ea9c614

Please sign in to comment.