Swift Generics

Posted by Den on June 20, 2018 · 4 mins read

Swift Generics

WWDC 2018

Swift Generics

WWDC 2018

Generics

Type safety, Memory
Wrap Common Algorithms in Methods

Designing a Protocol

Setting the Element Type
Constraining Index

Customization Points

Using Count in a Generic Context
Choosing When to Define Customization Points

Protocol Inheritance

BidirectionalCollection
Fisher-Yates Shuffle

Collection Protocol Hierarchy

Collection Protocol Hierarchy

Conditional Conformance

Slicing Collections

Range

Range Structures

Range as a Collection

Range conditionally conforms to RandomAccessCollection
CountableRange is a convenient alias for Ranges that are Collections

Protocol Conformances and Classes

Required initializers must be implemented by all subclasses