# Documentation of eachindex

**URL:** <https://discourse.julialang.org/t/documentation-of-eachindex/31607>\
**Category:** General Usage\
**Tags:** documentation, indexing\
**Created:** [November 28, 2019, 5:34am UTC](https://discourse.julialang.org/t/documentation-of-eachindex/31607 "2019-11-28T05:34:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmt/32/5192_2.png) [@emmt](https://discourse.julialang.org/u/emmt)\
**Post date:** [November 28, 2019, 5:34am UTC](https://discourse.julialang.org/t/documentation-of-eachindex/31607/1 "2019-11-28T05:34:44Z")

</div>

I find the documentation of `eachindex` a bit confusing when is says that:

> If the arrays have different sizes and/or dimensionalities,  
> `eachindex` will return an iterable that spans the largest range along each dimension.

But my undestanding of the implementation of `eachindex` in `abstractarray.jl` and `multidimensional.jl` is that all array arguments must have the same length (for linear indexing) or the same axes (for Cartesian indexing) otherwise `eachindex` throws a `DimensionMismatch` exception.

To me, this means that it is always safe to use `@inbounds` for a loop like:

```julia
for i in eachindex(A, B, C, D)
   A[i] = B[i]*C[i] + D[i]
end

```

when `A`, `B` etc. are all (abstract) arrays.

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [December 5, 2019, 7:10am UTC](https://discourse.julialang.org/t/documentation-of-eachindex/31607/2 "2019-12-05T07:10:52Z")

</div>

i found this on the release notes of Julia 1.0:

> `eachindex(A, B...)` now requires that all inputs have the same number of elements. When the chosen indexing is Cartesian, they must have the same axes.

so that documentation is outdated, i suppose
