---
title: "encode(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/unkeyedencodingcontainer/encode(_:)-6moq8"
---

# encode(_:)

Encodes the given value.

## Declaration

```swift
mutating func encode(_ value: UInt16) throws
```

## Parameters

- `value`: The value to encode.

## Discussion

Discussion note: EncodingError.invalidValue if the given value is invalid in the current context for this format.
