Generics and the Art of Inference Part 3 of 3

In the pre-generics days of Obj-C the only way to pass around things of unknown type was with an id type, but with Swift Generics/Protocols we can do things like Promises statically and safely with an associateType. Although large scale projects has been built in several Swift libraries already, we’ll look at how a barebones […]

Generics and the Art of Inference Part 2 of 3

Our example this round will be constructing/deconstructing a struct to and from a Dictionary.

Here is the basic definition of the struct we would like to encode/decode. We can define a protocol for this as simply:

Now we can extend our type to implement these, but before we do that let’s extend some […]