I know Structs are passed by value and classes are passed by reference in Swift.
I wonder if I create an array store elements which providing a protocol. These elements passed by value or reference?
Is it based on the definition of model a class or struct?
class ClassA: ProtocolA {
// something
}
struct StructA: ProtocolA {
// something
}
var arr: [ProtocolA] = [ClassA(), StructA()]
exampleFunction(arr[0]) // is it passed by reference
exampleFunction(arr[1]) // is it passed by value