不知道做了什麼,但先留著 protocol DecodableDefaultSource { associatedtype Value: Decodable static var defaultValue: Value { get } } enum DecodableDefault {} extension DecodableDefault { @propertyWrapper struct Wrapper<Source: DecodableDefaultSource > { typealias Value = Source . Value var wrappedValue = Source.defaultValue } } extension DecodableDefault . Wrapper : Decodable { init (from decoder: Decoder ) throws { let container = try decoder.singleValueContainer() wrappedValue = try container.decode(Value. self ) } } extension KeyedDecodingContainer { func decode<T>( _ type: DecodableDefault . Wrapper < T >.Type, forKey key: Key ) throws -> DecodableDefault . ...