diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index 0e4bfb83edb5d..b8667fcf12711 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -15,6 +15,29 @@ systemerror Fill array `A` with the value `x`. If `x` is an object reference, all elements will refer to the same object. `fill!(A, Foo())` will return `A` filled with the result of evaluating `Foo()` once. + +```jldoctest +julia> A = zeros(2,3) +2×3 Array{Float64,2}: + 0.0 0.0 0.0 + 0.0 0.0 0.0 + +julia> fill!(A, 2.) +2×3 Array{Float64,2}: + 2.0 2.0 2.0 + 2.0 2.0 2.0 + +julia> a = [1, 1, 1]; A = fill!(Vector{Vector{Int}}(3), a); a[1] = 2; A +3-element Array{Array{Int64,1},1}: + [2,1,1] + [2,1,1] + [2,1,1] + +julia> x = 0; f() = (global x += 1; x); fill!(Vector{Int}(3), f()) + 1 + 1 + 1 +``` """ fill!