Skip to content

Commit f805866

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

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

base/multidimensional.jl

+20
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,26 @@ module IteratorsMD
250250

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

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

0 commit comments

Comments
 (0)