mirror of
https://github.com/Dev1an/MsgPack.git
synced 2026-03-25 08:45:55 +00:00
Encode Optionals
This commit is contained in:
parent
e9907a8c50
commit
5eddff1fdc
2 changed files with 11 additions and 3 deletions
|
|
@ -46,7 +46,7 @@ extension MsgPack.Serialiser: SingleValueEncodingContainer {
|
|||
}
|
||||
|
||||
func encodeNil() throws {
|
||||
throw Error.notImplemented
|
||||
storage = .nil
|
||||
}
|
||||
|
||||
func encode(_ value: Bool) throws {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
//: Playground - noun: a place where people can play
|
||||
|
||||
import MsgPack
|
||||
import Foundation
|
||||
|
||||
var number: UInt16 = 0x0906
|
||||
var number: UInt16? = 0x0906
|
||||
|
||||
let data = try Encoder().encode(number)
|
||||
let encoder = Encoder()
|
||||
|
||||
let data = try encoder.encode(number)
|
||||
data[1]
|
||||
data[2]
|
||||
|
||||
number = nil
|
||||
|
||||
let data2 = try encoder.encode(number)
|
||||
data2[0]
|
||||
|
|
|
|||
Loading…
Reference in a new issue