Swift protocols and extensions?
Example:
protocol Describable {
func describe() -> String
}
extension Int: Describable {
func describe() -> String {
return "This is the number (self)"
}
}
print(5.describe()) // Outputs: This is the number 5
Solution:
Protocols define a blueprint of methods, properties, and other requirements for a particular task. Extensions add new functionality to an existing class, structure, enumeration, or protocol type.