Swift increment Int! not working
问题 I understand how optionals work, but this is throwing me for a loop. I have a variable called num and I want to increment it, so I did the following: var num:Int! = 0 num++ //ERROR - Unary operator ++ cannot be applied to an operand of type Int! But for some reason Swift won't let me increment a force unwrapped Int , even though it is supposed to be treated like a regular Int with the capability for nil behind the scenes. So I tried the following, and it worked: var num:Int! = 0 num = num + 1