Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify documentation for view to take into account range special case #38536

Merged
merged 7 commits into from
Nov 30, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ _maybe_reshape_parent(A::AbstractArray, ::NTuple{N, Bool}) where {N} = reshape(A
view(A, inds...)

Like [`getindex`](@ref), but returns a view into the parent array `A` with the
dlfivefifty marked this conversation as resolved.
Show resolved Hide resolved
given indices instead of making a copy. Calling [`getindex`](@ref) or
[`setindex!`](@ref) on the returned `SubArray` computes the
given indices instead of making a copy if (but not only if) `A` supports `setindex!`.
Otherwise, it may create a new object if that is a cheap operation (e.g., `UnitRange`).
Calling [`getindex`](@ref) or
[`setindex!`](@ref) on the returned value (usually a `SubArray`) computes the
dlfivefifty marked this conversation as resolved.
Show resolved Hide resolved
indices to the parent array on the fly without checking bounds.
dlfivefifty marked this conversation as resolved.
Show resolved Hide resolved

# Examples
Expand All @@ -148,6 +150,9 @@ julia> A # Note A has changed even though we modified b
2×2 Matrix{Int64}:
0 2
0 4

julia> view(2:5, 2:3) # returns a range as type is immutable
3:4
```
"""
function view(A::AbstractArray, I::Vararg{Any,N}) where {N}
Expand Down