This does not work because the compound assignment operator += expects the left side to be a mutable variable Int . When you pass it count , the compiler expands the implicitly expanded option and sends an immutable Int value instead, which cannot be passed as the inout that expects += .
If you really want to do this, you can overload += :
func += (left: inout Int!, right: Int) { left = left! + right }
Now += sends the left side as an implicitly expanded option without expanding it, and the expansion is performed explicitly inside the function.
var count: Int! = 10 count = count + 10
source share