Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What I Learned From 55* Swift Standard Library Protocols

Greg Heo
October 29, 2015

What I Learned From 55* Swift Standard Library Protocols

Greg Heo

October 29, 2015
Tweet

More Decks by Greg Heo

Other Decks in Technology

Transcript

  1. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType
  2. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType 1. Can do 2. Is a 3. Can be
  3. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType 1. Can do 2. Is a 3. Can be
  4. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType 1. Can do 2. Is a 3. Can be
  5. @gregheo public protocol MirrorPathType // Do not declare new conformances

    to this // protocol; they will not work as expected.

  6. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType 1. Can do 2. Is a 3. Can be
  7. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType 1. Can do 2. Is a 3. Can be
  8. @gregheo protocol EmployeeConvertible { func hire() -> Employee } class

    Contractor: EmployeeConvertible { // ... } class Interviewee: EmployeeConvertible { // ... }
  9. @gregheo protocol EmployeeConvertible { func hire() -> Employee } class

    Contractor: EmployeeConvertible { // ... } class Interviewee: EmployeeConvertible { // ... }
  10. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType 1. Can do 2. Is a 3. Can be
  11. @gregheo AbsoluteValuable, AnyCollectionType, AnyObject, ArrayLiteralConvertible, BidirectionalIndexType, BitwiseOperationsType, BooleanLiteralConvertible, BooleanType, CVarArgType,

    CollectionType, Comparable, CustomDebugStringConvertible, CustomLeafReflectable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, DictionaryLiteralConvertible, Equatable, ErrorType, ExtendedGraphemeClusterLiteralConvertible, FloatLiteralConvertible, FloatingPointType, ForwardIndexType, GeneratorType, Hashable, Indexable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, IntervalType, LazyCollectionType, LazySequenceType, MirrorPathType, MutableCollectionType, MutableIndexable, MutableSliceable, NilLiteralConvertible, OptionSetType, OutputStreamType, RandomAccessIndexType, RangeReplaceableCollectionType, RawRepresentable, ReverseIndexType, SequenceType, SetAlgebraType, SignedIntegerType, SignedNumberType, Streamable, Strideable, StringInterpolationConvertible, StringLiteralConvertible, UnicodeCodecType, UnicodeScalarLiteralConvertible, UnsignedIntegerType 1. Can do 2. Is a 3. Can be