環境
- Julia 1.3.0
配列の要素が undef
か否かを調べる時は isassigned
を使う
julia> v = Vector{Any}(undef, 5) 5-element Array{Any,1}: #undef #undef #undef #undef #undef julia> v[1:3] .= 'a':'c' 3-element view(::Array{Any,1}, 1:3) with eltype Any: 'a' 'b' 'c' julia> v[1:3] = 'a':'c' 'a':1:'c' julia> v 5-element Array{Any,1}: 'a' 'b' 'c' #undef #undef julia> v = Vector{Any}(undef, 5) 5-element Array{Any,1}: #undef #undef #undef #undef #undef julia> v[1:3] = 'a':'c' 'a':1:'c' julia> v 5-element Array{Any,1}: 'a' 'b' 'c' #undef #undef julia> isassigned(v, 1) true julia> isassigned(v, 2) true julia> isassigned(v, 3) true julia> isassigned(v, 4) false julia> isassigned(v, 5) false