# Initialising a dictionary with duplicate keys

**URL:** <https://discourse.julialang.org/t/initialising-a-dictionary-with-duplicate-keys/2290>\
**Category:** General Usage\
**Created:** [February 25, 2017, 1:15am UTC](https://discourse.julialang.org/t/initialising-a-dictionary-with-duplicate-keys/2290 "2017-02-25T01:15:54Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [February 25, 2017, 10:17am UTC](https://discourse.julialang.org/t/initialising-a-dictionary-with-duplicate-keys/2290/3 "2017-02-25T10:17:33Z")

</div>

If you, for some reason, want to have dictionary with duplicate keys you can use `Base.ImmutableDict` (which is however a bit tricky to use):

```julia
julia> a = Base.ImmutableDict(Base.ImmutableDict(Pair(:x, 1)), Pair(:x, 2))
Base.ImmutableDict{Symbol,Int64} with 2 entries:
  :x => 2
  :x => 1

```

Note that adding a new value with the same key will override the initial definition, so

```julia
julia> a[:x]
2

```

---

_[View the full topic](https://discourse.julialang.org/t/initialising-a-dictionary-with-duplicate-keys/2290)._
