---
title: "decodeNil(forKey:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/keyeddecodingcontainerprotocol/decodenil(forkey:)"
---

# decodeNil(forKey:)

Decodes a null value for the given key.

## Declaration

```swift
func decodeNil(forKey key: Self.Key) throws -> Bool
```

## Parameters

- `key`: The key that the decoded value is associated with.

## Return Value

Return Value Whether the encountered value was null.

## Discussion

Discussion note: DecodingError.keyNotFound if self does not have an entry for the given key.
