# Zero-based indexing ... (not) again

**URL:** https://discourse.julialang.org/t/zero-based-indexing-not-again/100944
**Category:** General Usage
**Created:** [June 28, 2023, 7:43pm UTC](https://discourse.julialang.org/t/zero-based-indexing-not-again/100944 "2023-06-28T19:43:31Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [June 29, 2023, 1:22am UTC](https://discourse.julialang.org/t/zero-based-indexing-not-again/100944/6 "2023-06-29T01:22:43Z")

</div>

I’d rather use OffsetArrays to guarantee I’m using 0-based arrays than alter my indexing.  
Arrays with different indices often have different indices for a reason, so when I have to work with those I wouldn’t usually write indices that disregard that. That’s not really a dealbreaker though because when I need to disregard them, I would use `begin`/`end`, and using `@absolutezero` is intended for the same thing with `0`/whatever. The bigger problem is that this doesn’t cover a lot of expressions I could put in the brackets. Here’s a simple one:

```julia
julia> x = 1:9
1:9

julia> x[begin] == x[begin .+ 0] # @absolutezero x[0]
true

julia> x[:] == x[:] # @absolutezero x[:]
true

julia> x[begin] == x[begin .+ begin] # @absolutezero x[begin]
false

```

`begin` stands in for the method call `firstindex(x)`, and I could be calling much more complicated methods to find an index. `begin .+ some_method(x, inputs...)` isn’t always what I want (for example, if it returns `:`), and it might not even be possible if addition is not defined for the indices type’s values.

---

_[View the full topic](https://discourse.julialang.org/t/zero-based-indexing-not-again/100944)._
