I've been reading the documentation and apparently protocols force structures, classes or enumerations to implement specific methods or define certain variables.
I've double checked this functionality by typing the following code. In fact, xcode compiler helped me to verify this since it popped up an alert that depicted the following message : "Type MiguelStruc does not conform to protocol Miguels ..."
protocol Miguels {
func someF()-> Float
}
public struct MiguelStruc{
var miguelVar : String = "hey"
}
extension MiguelStruc: Miguels{
}
Now, while I was following the official swiftUI drawing paths and shapes tutorial I encountered this particular chain of code: (https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes)
Path { path in
}
.fill(.black)
By diving into the Swiftui documentation I noticed that Shape is a protocol
public protocol Shape : Sendable, Animatable, View
which is implemented by the Path structure
extension Path : Shape
Why none of the Path extensions content are explicitly implementing any of the Shape protocol requirements?
such as role, layoutDirectionBehavior, sizeThatFits, offset, intersection, union, and so on!