Encode Optionals

This commit is contained in:
Damiaan Dufaux 2017-07-31 15:26:20 +02:00
parent e9907a8c50
commit 5eddff1fdc
2 changed files with 11 additions and 3 deletions

View file

@ -46,7 +46,7 @@ extension MsgPack.Serialiser: SingleValueEncodingContainer {
} }
func encodeNil() throws { func encodeNil() throws {
throw Error.notImplemented storage = .nil
} }
func encode(_ value: Bool) throws { func encode(_ value: Bool) throws {

View file

@ -1,9 +1,17 @@
//: Playground - noun: a place where people can play //: Playground - noun: a place where people can play
import MsgPack 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[1]
data[2] data[2]
number = nil
let data2 = try encoder.encode(number)
data2[0]