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

# encodeIfPresent(_:forKey:configuration:)

## Declaration

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