Skip to content

Commit e6b9482

Browse files
committed
Docs and compat annotation for #29440 (colon constructor of CartesianIndices).
1 parent 25ca508 commit e6b9482

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

base/multidimensional.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,26 @@ module IteratorsMD
249249

250250
CartesianIndices(A::AbstractArray) = CartesianIndices(axes(A))
251251

252+
"""
253+
(:)(I::CartesianIndex, J::CartesianIndex)
254+
255+
Construct [`CartesianIndices`](@ref) from two `CartesianIndex`.
256+
257+
!!! compat "Julia 1.1"
258+
This method requires at least Julia 1.1.
259+
260+
# Examples
261+
```jldoctest
262+
julia> I = CartesianIndex(2,1);
263+
264+
julia> J = CartesianIndex(3,3);
265+
266+
julia> I:J
267+
2×3 CartesianIndices{2,Tuple{UnitRange{Int64},UnitRange{Int64}}}:
268+
CartesianIndex(2, 1) CartesianIndex(2, 2) CartesianIndex(2, 3)
269+
CartesianIndex(3, 1) CartesianIndex(3, 2) CartesianIndex(3, 3)
270+
```
271+
"""
252272
(:)(I::CartesianIndex{N}, J::CartesianIndex{N}) where N =
253273
CartesianIndices(map((i,j) -> i:j, Tuple(I), Tuple(J)))
254274

0 commit comments

Comments
 (0)