Protocols
Overview
Sample Codes
protocol Vehicle {
// Properties
var name: String { get } // car, bike, etc.
var currentPassengers: Int { get set } // number passengers in default
// Methods
func estimateTime(for distance: Int) -> Int
func travel(distance: Int)
}Technical Protocol Inheritance
Protocol Conformance
Sources: HWS,
get / get set
self vs Self
Protocol Extensions
They let us add functionality to many types all at once.
Protocols cannot have boddies, bodies can only be in extensions
Opaque return types
Sources
Videos
Articles / Documents
See Also
Last updated