I've created a struct called 'Code', which contains a string and generic property. So, now I'm trying to create a method, which is going to work with the array of Code elements. But the problem is that I'm not aware about the protocol that T-elements should conform to perform + operator.
struct Code<Element>{
let probability: Element
let code: String
}
func createTree<T>(_ array: [Code<T>]){
for i in 0..<array.count-1{
let sum = array[i].probability + array[i+1].probability
}
}
Thanks for your help!