[swift-users] Array<T> not Encodable - error at runtime, not compile time?
Robert Nikander
robert.nikander at icloud.com
Thu Oct 26 11:46:49 CDT 2017
Hi,
This error makes perfect sense, but I’m surprised it's a runtime error. I expected it at compile time. Am I doing something wrong? Is this on the type system to-do list?
let c = JSONEncoder()
struct Foo { … }
let fs: [Foo] = [ Foo(...) ]
let data = try! c.encode(fs) // Didn’t think this would compile
The runtime error is: fatal error: Array<Foo> does not conform to Encodable because Foo does not conform to Encodable.
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171026/b6ad1145/attachment.html>
More information about the swift-users
mailing list