# Is there a keyword opposite of 'end' when indexing

**URL:** https://discourse.julialang.org/t/is-there-a-keyword-opposite-of-end-when-indexing/133714
**Category:** New to Julia
**Created:** [November 6, 2025, 5:04pm UTC](https://discourse.julialang.org/t/is-there-a-keyword-opposite-of-end-when-indexing/133714 "2025-11-06T17:04:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Queenvictoria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/queenvictoria/32/218740_2.png) [@Queenvictoria](https://discourse.julialang.org/u/Queenvictoria)
#### Post date: [November 6, 2025, 5:04pm UTC](https://discourse.julialang.org/t/is-there-a-keyword-opposite-of-end-when-indexing/133714/1 "2025-11-06T17:04:46Z")

</div>

name[end] gives you the last value. But when I learned it, I could’ve sworn there was a keyword for the very first value. Obviously you can just index at one, but does that keyword exist? Or did I make it up?

---

<div class="post-metadata">

### Author: ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)
#### Post date: [November 6, 2025, 5:13pm UTC](https://discourse.julialang.org/t/is-there-a-keyword-opposite-of-end-when-indexing/133714/2 "2025-11-06T17:13:10Z")

</div>

If I recall correctly, that would be ‘’ `arrayname[begin]`, but checking this on my phone is a bit tricky.

---

<div class="post-metadata">

### Author: ![NonDairyNeutrino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nondairyneutrino/32/221496_2.png) [@NonDairyNeutrino](https://discourse.julialang.org/u/NonDairyNeutrino)
#### Post date: [November 6, 2025, 6:18pm UTC](https://discourse.julialang.org/t/is-there-a-keyword-opposite-of-end-when-indexing/133714/3 "2025-11-06T18:18:55Z")

</div>

While `begin` and `end` are used to create a block of code, they can also be used as “indices” to _safely_ get the first and last elements of a collection. While `Array`s do index starting at 1, that’s not always the case e.g. OffsetArrays.jl or just because [`getindex`](https://docs.julialang.org/en/v1/base/arrays/#Base.getindex-Tuple%7BAbstractArray,%20Vararg%7BAny%7D) is a function for which an abitrary method could be created e.g. `Base.getindex() = 2` (wow I hate that).

From the [documentation](https://docs.julialang.org/en/v1/base/base/#begin)

```julia-auto
begin

  begin...end denotes a block of code.

  begin
      println("Hello, ")
      println("World!")
  end

  Usually begin will not be necessary, since keywords such as function and let implicitly begin blocks of code. See also ;.

  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. For example, a[begin]
  is the first element of an array a.

  │ Julia 1.4
  │
  │ Use of begin as an index requires Julia 1.4 or later.

  Examples
  ≡≡≡≡≡≡≡≡

  julia> A = [1 2; 3 4]
  2×2 Matrix{Int64}:
   1 2
   3 4

  julia> A[begin, :]
  2-element Matrix{Int64}:
   1
   2

```

Similarly for [`end`](https://docs.julialang.org/en/v1/base/base/#end)

```julia-auto
end

  end marks the conclusion of a block of expressions, for example module, struct, mutable struct, begin, let, for etc.

  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
  ≡≡≡≡≡≡≡≡

  julia> A = [1 2; 3 4]
  2×2 Matrix{Int64}:
   1 2
   3 4

  julia> A[end, :]
  2-element Vector{Int64}:
   3
   4

```
