Swift 6 · Types and protocols
Protocols and extensions
A protocol describes requirements, and an extension adds default behavior.
protocol Describable {
var name: String { get }
}
extension Describable {
func describe() -> String { "I am \(name)" }
}
struct Dog: Describable { let name: String }
Official Swift 6 documentation