File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 232
232
//// use name <- decode.field("name", decode.string)
233
233
//// use badge_count <- decode.field("badge-count", decode.int)
234
234
//// decode.success(Trainer(name, badge_count))
235
- //// })
235
+ //// }
236
236
////
237
237
//// let gym_leader_decoder = {
238
238
//// use name <- decode.field("name", decode.string)
242
242
//// ```
243
243
////
244
244
//// A third decoder can be used to extract and decode the `"type"` field, and the
245
- //// `then` function then returns whichever decoder is suitable for the document.
245
+ //// expression can evaluate to whichever decoder is suitable for the document.
246
246
////
247
247
//// ```gleam
248
+ //// // Data:
249
+ //// // {
250
+ //// // "type" -> "gym-leader",
251
+ //// // "name" -> "Misty",
252
+ //// // "speciality" -> "water",
253
+ //// // }
254
+ ////
248
255
//// let decoder = {
249
256
//// use tag <- decode.field("type", decode.string)
250
257
//// case tag {
253
260
//// }
254
261
//// }
255
262
////
256
- //// decode.run(data, decoder)
263
+ //// let result = decode.run(data, decoder)
264
+ //// assert result == Ok(GymLeader("Misty", Water))
257
265
//// ```
258
266
259
267
import gleam/bit_array
You can’t perform that action at this time.
0 commit comments