# How to best iterate over k-dimensional collection, e.g. (n,k) matrix?

**URL:** <https://discourse.julialang.org/t/how-to-best-iterate-over-k-dimensional-collection-e-g-n-k-matrix/92328>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [December 30, 2022, 7:07pm UTC](https://discourse.julialang.org/t/how-to-best-iterate-over-k-dimensional-collection-e-g-n-k-matrix/92328 "2022-12-30T19:07:37Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [December 30, 2022, 10:44pm UTC](https://discourse.julialang.org/t/how-to-best-iterate-over-k-dimensional-collection-e-g-n-k-matrix/92328/3 "2022-12-30T22:44:23Z")

</div>

Other possible options can be found here (with bonus benchmarking, although they are probably dated):

> [@How much can hard-coded indexing be avoided in Julia?](https://discourse.julialang.org/t/how-much-can-hard-coded-indexing-be-avoided-in-julia/55699):
>
> I’ve noticed a trend toward Julia’s new keywords trending towards using keywords and functions instead of integer indexing in Julia. For example, first(array) instead of array[1], or eachindex(array) instead of 1:length(array). Is this an intended aim for Julia style-- to avoid integer indexes in code that can avoid it? How likely is it that in the future Julia code will not need to show its 1-based integer heritage in common written code?

---

_[View the full topic](https://discourse.julialang.org/t/how-to-best-iterate-over-k-dimensional-collection-e-g-n-k-matrix/92328)._
