---
title: "encodeIfPresent(_:forKey:configuration:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/keyedencodingcontainer/encodeifpresent(_:forkey:configuration:)-7bzb4"
---

# encodeIfPresent(_:forKey:configuration:)

## Declaration

```swift
mutating func encodeIfPresent<T>(_ t: T?, forKey key: KeyedEncodingContainer<K>.Key, configuration: T.EncodingConfiguration) throws where T : EncodableWithConfiguration
```
