Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftCodable custom keysSingle-choice MCQ

During encoding with `encodeIfPresent`, what is emitted for a nil Optional?

struct Settings: Encodable { var theme: String? func encode(to encoder: Encoder) throws { var c = encoder.container(keyedBy: CodingKeys.self) try c.encodeIfPresent(theme, forKey: .theme) } enum CodingKeys: String, CodingKey { case theme } } // theme == nil