# Why does using keys() on an array produce LinearIndices?

**URL:** <https://discourse.julialang.org/t/why-does-using-keys-on-an-array-produce-linearindices/57618>\
**Category:** General Usage\
**Created:** [March 20, 2021, 6:31pm UTC](https://discourse.julialang.org/t/why-does-using-keys-on-an-array-produce-linearindices/57618 "2021-03-20T18:31:28Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![anon60034542](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Post date:** [March 21, 2021, 5:10pm UTC](https://discourse.julialang.org/t/why-does-using-keys-on-an-array-produce-linearindices/57618/6 "2021-03-21T17:10:04Z")

</div>

> [@Tamas\_Papp](#):
>
> In addition to the answers above: I would just treat the internals of `LinearIndices` as an implementation detail. The main point is that it is an object on which you can `iterate` .
> 
> Actually, in this context even `LinearIndices` itself is an implementation detail. It’s just something that `keys` returns.

Seeing as you brought up implementation details, I was wondering if you could clarify something for me. I asked [a question about keyword arguments and how they’re stored](https://discourse.julialang.org/t/is-using-values-the-correct-way-to-obtain-the-namedtuple-in-keyword-arguments/55074), but I wasn’t really satisfied with the answer, so I was hoping to get a second opinion.

When a structure (`NamedTuple`,`LinearIndices`,etc) is considered an implementations detail, is to okay to use that structure?

In the case of keyword arguments, it’s really a `Iterator.Pairs()` holding a `NamedTuple`, and the documentation clearly states it. You can use `values()` to extract the `NameTuple` and access the elements by keywords. However, does relying on it being a `NamedTuple` make the code fragile? I’m assuming if it does change in the future, the documentation would be updated to reflect that, and even if it isn’t, you can call `typeof()` to view the type of structure. Would it be better to create your own `NamedTuple` as demonstrated in the linked answer?

In the context of `LinearIndices`, should I just rely on the fact I have an iterable, rather than a more specific structure?

---

_[View the full topic](https://discourse.julialang.org/t/why-does-using-keys-on-an-array-produce-linearindices/57618)._
