Cannot invoke “+=” with an argument list of type (Int, @value Int)
问题 I have a class Transaction which has a var amount of type Int . I want to access it from another class, where I have an array of Transactions and sum all of their amounts. So I have this piece of 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 } But it gives me an error Cannot invoke "+=" with an argument list of type (Int, @value Int) What can cause that? I know that in