Kann nicht "+ =" mit einer Argumentliste vom Typ (Int, @value Int) aufrufen
Ich habe ein klasseTransaction
das hat einvar Betrag vom TypInt
. Ich möchte von einer anderen Klasse darauf zugreifen, wo ich ein @ haarray of Transactions
und summiere alle ihre Beträge.
So habe ich dieses Stück Code
func computeTotal()-> Int{
let total = 0
for transaction in transactions{
//get the amounts of each and sum all of them up
total += transaction.amount
}
return total
}
Aber es gibt mir einen Fehler
Kann nicht "+ =" mit einer Argumentliste vom Typ (Int, @value Int) aufrufen
Was kann das verursachen? Ich weiß, dass in Swift beide Operanden den gleichen Typ haben müssen, aber sie haben beide den Typ Int in meinem Code.