Undefined values: Difference between revisions

Line 614:
[1] top-level scope at none:0
</code>
2. For variables that are defined for the Julia program but have undefined values, there are two different notions of undefined value in Julia (version > 0.7): <code> nothing </code> and <code> missing </code>. "nothing" and "missing" are typed constants used by convention to refer to either (with <code> nothing </code>) an absent result, such as a search with nothing found, or in the case of <code> missing, </code> a data location containing a missing value, such as a data table with missing values. <code>nothing</code> produces an error if any calculations incorporate it, but <code>missing</code> can be propagated along a calculation:
<lang julia>
julia> arr = [1, 2, nothing, 3]
4-element Array{Union{Nothing, Int64},1}:
1
2
nothing
3
 
julia> x = arr .+ 5
ERROR: MethodError: no method matching +(::Nothing, ::Int64)
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any...) at operators.jl:502
+(::Complex{Bool}, ::Real) at complex.jl:292
+(::Missing, ::Number) at missing.jl:93
...
 
julia> arr = [1, 2, missing, 3]
4-element Array{Union{Missing, Int64},1}:
1
2
missing
3
 
julia> x = arr .+ 5
4-element Array{Union{Missing, Int64},1}:
6
7
missing
8
</lang>
 
=={{header|Kotlin}}==
4,105

edits