---
title: "init(dictionaryLiteral:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/dictionary/init(dictionaryliteral:)"
---

# init(dictionaryLiteral:)

Creates a dictionary initialized with a dictionary literal.

## Declaration

```swift
init(dictionaryLiteral elements: (Key, Value)...)
```

## Parameters

- `elements`: The key-value pairs that will make up the new dictionary. Each key in elements must be unique.

## Discussion

Discussion Do not call this initializer directly. It is called by the compiler to handle dictionary literals. To use a dictionary literal as the initial value of a dictionary, enclose a comma-separated list of key-value pairs in square brackets. For example, the code sample below creates a dictionary with string keys and values. let countryCodes = ["BR": "Brazil", "GH": "Ghana", "JP": "Japan"] print(countryCodes) // Prints "["BR": "Brazil", "JP": "Japan", "GH": "Ghana"]"

## See Also

### Infrequently Used Functionality

- [hashValue](swift/dictionary/hashvalue.md)
