Skip to content

Commit

Permalink
docs: document use of begin as index (JuliaLang#39860)
Browse files Browse the repository at this point in the history
And clarify that it's not just for arrays.
  • Loading branch information
cmcaine authored and antoine-levitt committed May 9, 2021
1 parent ce9e61f commit e90c51b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,9 @@ kw"while"
`end` marks the conclusion of a block of expressions, for example
[`module`](@ref), [`struct`](@ref), [`mutable struct`](@ref),
[`begin`](@ref), [`let`](@ref), [`for`](@ref) etc.
`end` may also be used when indexing into an array to represent
the last index of a dimension.
`end` may also be used when indexing to represent the last index of a
collection or the last index of a dimension of an array.
# Examples
```jldoctest
Expand Down Expand Up @@ -1017,6 +1018,22 @@ end
Usually `begin` will not be necessary, since keywords such as [`function`](@ref) and [`let`](@ref)
implicitly begin blocks of code. See also [`;`](@ref).
`begin` may also be used when indexing to represent the first index of a
collection or the first index of a dimension of an array.
# Examples
```jldoctest
julia> A = [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> A[begin, :]
2-element Array{Int64,1}:
1
2
```
"""
kw"begin"

Expand Down

0 comments on commit e90c51b

Please sign in to comment.