# \`eachindex(x)\` replacement for \`1:length(x)-1\` and similar

**URL:** <https://discourse.julialang.org/t/eachindex-x-replacement-for-1-length-x-1-and-similar/81481>\
**Category:** General Usage\
**Created:** [May 23, 2022, 2:49am UTC](https://discourse.julialang.org/t/eachindex-x-replacement-for-1-length-x-1-and-similar/81481 "2022-05-23T02:49:26Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [May 23, 2022, 5:15am UTC](https://discourse.julialang.org/t/eachindex-x-replacement-for-1-length-x-1-and-similar/81481/9 "2022-05-23T05:15:41Z")

</div>

[`AbstractArray`s must have `AbstractUnitRange` axes](https://discourse.julialang.org/t/offsetarrays-inbounds-and-confusion/81295/50), so such a situation isn’t worth preparing for.

---

_[View the full topic](https://discourse.julialang.org/t/eachindex-x-replacement-for-1-length-x-1-and-similar/81481)._
