Skip to content

Commit 60eb238

Browse files
authored
Merge pull request #42399 from JuliaLang/ksh/copytodoctest
Add a doctest for copyto with CartesianIndices
2 parents 84cc901 + 69d8c1e commit 60eb238

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

base/multidimensional.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,25 @@ end
11271127
11281128
Copy the block of `src` in the range of `Rsrc` to the block of `dest`
11291129
in the range of `Rdest`. The sizes of the two regions must match.
1130+
1131+
# Examples
1132+
```jldoctest
1133+
julia> A = zeros(5, 5);
1134+
1135+
julia> B = [1 2; 3 4];
1136+
1137+
julia> Ainds = CartesianIndices((2:3, 2:3));
1138+
1139+
julia> Binds = CartesianIndices(B);
1140+
1141+
julia> copyto!(A, Ainds, B, Binds)
1142+
5×5 Matrix{Float64}:
1143+
0.0 0.0 0.0 0.0 0.0
1144+
0.0 1.0 2.0 0.0 0.0
1145+
0.0 3.0 4.0 0.0 0.0
1146+
0.0 0.0 0.0 0.0 0.0
1147+
0.0 0.0 0.0 0.0 0.0
1148+
```
11301149
"""
11311150
copyto!(::AbstractArray, ::CartesianIndices, ::AbstractArray, ::CartesianIndices)
11321151

0 commit comments

Comments
 (0)