Skip to content

Commit 867e27b

Browse files
authored
Update README.md
1 parent b675789 commit 867e27b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The encoding of `Optional.none` can be adjusted by setting the strategy.
6464
The default strategy preserves `Optional.none`:
6565

6666
```swift
67-
let encoder = KeyValueEncoder()
67+
var encoder = KeyValueEncoder()
6868
encoder.nilEncodingStrategy = .default
6969

7070
// [1, 2, nil, 3]
@@ -115,7 +115,7 @@ _ = try KeyValueDecoder().decode(Int8.self, from: 1000])
115115
Values with a fractional part can also be decoded to integers by rounding with any [`FloatingPointRoundingRule`](https://developer.apple.com/documentation/swift/floatingpointroundingrule):
116116

117117
```swift
118-
let decoder = KeyValueDecoder()
118+
var decoder = KeyValueDecoder()
119119
decoder.intDecodingStrategy = .rounding(rule: .toNearestOrAwayFromZero)
120120

121121
// [10, -21, 50]
@@ -125,7 +125,7 @@ let values = try decoder.decode([Int].self, from: [10.1, -20.9, 50.00001]),
125125
Values can also be clamped to the representable range:
126126

127127
```swift
128-
let decoder = KeyValueDecoder()
128+
var decoder = KeyValueDecoder()
129129
decoder.intDecodingStrategy = .clamping(roundingRule: .toNearestOrAwayFromZero)
130130

131131
// [10, 21, 127, -128]

0 commit comments

Comments
 (0)