Skip to content

Commit

Permalink
Add CartesianIndex to getindex docstring (JuliaLang#51567)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Bauman <mbauman@gmail.com>
Co-authored-by: Denis Barucic <barucic.d@gmail.com>
Co-authored-by: Jishnu Bhattacharya <jishnub.github@gmail.com>
Co-authored-by: Max Horn <max@quendi.de>
  • Loading branch information
5 people authored and tecosaur committed Mar 4, 2024
1 parent de2d615 commit 7e91333
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,11 @@ end
"""
getindex(A, inds...)
Return a subset of array `A` as specified by `inds`, where each `ind` may be,
for example, an `Int`, an [`AbstractRange`](@ref), or a [`Vector`](@ref).
Return a subset of array `A` as selected by the indices `inds`.
Each index may be any [supported index type](@ref man-supported-index-types), such
as an [`Integer`](@ref), [`CartesianIndex`](@ref), [range](@ref Base.AbstractRange), or [array](@ref man-multi-dim-arrays) of supported indices.
A [:](@ref Base.Colon) may be used to select all elements along a specific dimension, and a boolean array (e.g. an `Array{Bool}` or a [`BitArray`](@ref)) may be used to filter for elements where the corresponding index is `true`.
When `inds` selects multiple elements, this function returns a newly
allocated array. To index multiple elements without making a copy,
Expand Down Expand Up @@ -1303,6 +1306,27 @@ julia> getindex(A, 2:4)
3
2
4
julia> getindex(A, 2, 1)
3
julia> getindex(A, CartesianIndex(2, 1))
3
julia> getindex(A, :, 2)
2-element Vector{Int64}:
2
4
julia> getindex(A, 2, :)
2-element Vector{Int64}:
3
4
julia> getindex(A, A .> 2)
2-element Vector{Int64}:
3
4
```
"""
function getindex(A::AbstractArray, I...)
Expand Down

0 comments on commit 7e91333

Please sign in to comment.