I'm trying to create Swift
Protocol
with Variadic
property. According to the docs, it's possible to do it in a function:
func arithmeticMean(_ numbers: Double...) -> Double {
var total: Double = 0
for number in numbers {
total += number
}
return total / Double(numbers.count)
}
arithmeticMean(1, 2, 3, 4, 5)
But trying to create Variadic
parameter inside a protocol like follows:
struct ProductModel {
}
protocol SubscriptionModel {
var products: ProductModel... { get set }
}
Is it not possible to create a Variadic
property within a Protocol
?