---
title: "encode(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/singlevalueencodingcontainer/encode(_:)-23skf"
---

# encode(_:)

Encodes a single value of the given type.

## Declaration

```swift
mutating func encode(_ value: Double) 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. note: May not be called after a previous self.encode(_:) call.
