I\'m trying to do something along the lines of this:
protocol Protocol {
associatedtype T
associatedtype ArrayT = Array
}
struct Struct
The line associatedtype ArrayT = Array
only tells the compiler that the default value of ArrayT
is Array
. An adaption of the protocol can still change ArrayT
like:
struct U: Protocol {
typealias T = UInt32
typealias ArrayT = UInt64 // <-- valid!
}
If you want a fixed type, you should use a typealias...
// does not work yet.
protocol Protocol {
associatedtype T
typealias ArrayT = Array
}
But the compiler complains that the type is too complex