From 80747267edea739b506f54cde45d4375fac50679 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Tue, 14 Aug 2018 13:35:16 -0400 Subject: [PATCH] Add doctest example for broadcast! --- base/broadcast.jl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/base/broadcast.jl b/base/broadcast.jl index 88d83d2377e19..a95cc8bbfed29 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -713,6 +713,30 @@ Like [`broadcast`](@ref), but store the result of Note that `dest` is only used to store the result, and does not supply arguments to `f` unless it is also listed in the `As`, as in `broadcast!(f, A, A, B)` to perform `A[:] = broadcast(f, A, B)`. + +# Examples +```jldoctest +julia> A = [1.0; 0.0]; B = [0.0; 0.0]; + +julia> broadcast!(+, B, A, (0, -2.0)); + +julia> B +2-element Array{Float64,1}: + 1.0 + -2.0 + +julia> A +2-element Array{Float64,1}: + 1.0 + 0.0 + +julia> broadcast!(+, A, A, (0, -2.0)); + +julia> A +2-element Array{Float64,1}: + 1.0 + -2.0 +``` """ broadcast!(f::Tf, dest, As::Vararg{Any,N}) where {Tf,N} = (materialize!(dest, broadcasted(f, As...)); dest)