---
title: "init(nilLiteral:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/optional/init(nilliteral:)"
---

# init(nilLiteral:)

Creates an instance initialized with nil.

## Declaration

```swift
init(nilLiteral: ())
```

## Discussion

Discussion Do not call this initializer directly. It is used by the compiler when you initialize an Optional instance with a nil literal. For example: var i: Index? = nil In this example, the assignment to the i variable calls this initializer behind the scenes.

## See Also

### Creating a Nil Value

- [Optional.none](swift/optional/none.md)
