Type MethodFoundationEssentials
encode(_:to:)
iOS 15.0+
iPadOS 15.0+
Mac Catalyst 15.0+
macOS 12.0+
tvOS 15.0+
watchOS 8.0+
Encodes a Swift value to the provided encoder, using a default implementation.
static func encode(_ value: Self.Value, to encoder: any Encoder) throws
Parameters
valueThe value to encode.
encoderThe encoder to write data to.
Discussion
The default implementation calls down to the value’s Encodable.encode(to:) method.
This method throws an error if writing the encoder fails.