# Accessing Dict of tuples

**URL:** <https://discourse.julialang.org/t/accessing-dict-of-tuples/18816>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 18, 2018, 11:04pm UTC](https://discourse.julialang.org/t/accessing-dict-of-tuples/18816 "2018-12-18T23:04:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [December 18, 2018, 11:04pm UTC](https://discourse.julialang.org/t/accessing-dict-of-tuples/18816/1 "2018-12-18T23:04:45Z")

</div>

I just realized you can access a Dict of tuples passing the tuple with the extra parens. Has this always been the case? Or is this a recent addition to the language?

For example,

```julia
d = Dict((a,i) => randn() for a = 1:5 for i = 1:10)
@assert d[3,4] == d[(3,4)]

```

Why is the tuple here being automatically splatted?

---

<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:** [December 18, 2018, 11:35pm UTC](https://discourse.julialang.org/t/accessing-dict-of-tuples/18816/2 "2018-12-18T23:35:44Z")

</div>

`@edit d[3,4]` shows the relevant code:

```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...))

```

and this works at least as far back as Julia 0.4.

Note that the parens aren’t ‘extra’: the `d[(3, 4)]` syntax is directly accessing the dictionary at the key `(3, 4)`, while the `d[3, 4]` syntax is just syntactic sugar to save some keystrokes.
