Instance Method

decodeIfPresent(_:)

Decodes a value of the given type, if present.

Required. Default implementation provided.

Declaration

mutating func decodeIfPresent(_ type: Bool.Type) throws -> Bool?

Parameters

type

The type of value to decode.

Return Value

A decoded value of the requested type, or nil if the value is a null value, or if there are no more elements to decode.

Discussion

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.