# Dict index with multiple keys versus tuple

**URL:** https://discourse.julialang.org/t/dict-index-with-multiple-keys-versus-tuple/86352
**Category:** New to Julia
**Created:** [August 25, 2022, 5:54pm UTC](https://discourse.julialang.org/t/dict-index-with-multiple-keys-versus-tuple/86352 "2022-08-25T17:54:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![healyp](https://avatars.discourse-cdn.com/v4/letter/h/67e7ee/32.png) [@healyp](https://discourse.julialang.org/u/healyp)
#### Post date: [August 25, 2022, 5:54pm UTC](https://discourse.julialang.org/t/dict-index-with-multiple-keys-versus-tuple/86352/1 "2022-08-25T17:54:17Z")

</div>

As I struggle to scale the slopes of julia sagacity I encountered the following and the fact that it didn’t throw an error, well, threw me.

```julia
julia> Acc_rd
Dict{Tuple{Int64, Int64}, Vector{Int64}} with 12 entries:
  (101521, 12124) => [23434]
  (101521, 9412) => []
  (100105, 7207) => [20661, 20662, 20911, 20912, 21111, 21112, 21113, 21114, 21181, 21182 … 26…
  (102653, 12124) => [20911, 20912, 22311, 22314, 23431, 24971, 25901, 25902, 26351, 26352]
     :

```

and then

```julia
julia> Acc_rd[101521, 12124]
1-element Vector{Int64}:
 23434

```

I’ve no doubt that there is some magic happening behind the scenes that “fills in the blanks” but I can’t help having the feeling that at some point features become counter-productive.

As I said at the outset, spare a thought…

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [August 25, 2022, 5:58pm UTC](https://discourse.julialang.org/t/dict-index-with-multiple-keys-versus-tuple/86352/2 "2022-08-25T17:58:47Z")

</div>

`Acc_rd[101521, 12124]` is equivalent to `Acc_rd[(101521, 12124)]`. This was very arguably a bad idea, but it made it into Julia 1.0, so it’s here to stay at least until Julia 2.0.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [August 25, 2022, 6:38pm UTC](https://discourse.julialang.org/t/dict-index-with-multiple-keys-versus-tuple/86352/3 "2022-08-25T18:38:03Z")

</div>

BTW, if you want to see the magic for yourself, just do:

```julia
@edit Acc_rd[101521, 12124]

```

which should point you to:

```julia
# t[k1,k2,ks...] is syntactic sugar for t[(k1,k2,ks...)]. (Note
# that we need to avoid dispatch loops if setindex!(t,v,k) is not defined.)
getindex(t::AbstractDict, k1, k2, ks...) = getindex(t, tuple(k1,k2,ks...))

```
