![iOS 12 Programming for Beginners](https://wfqqreader-1252317822.image.myqcloud.com/cover/76/36699076/b_36699076.jpg)
上QQ阅读APP看书,第一时间看更新
Increment and decrement
There are times when you need to increment (increase) or decrement (decrease) a value. There are two ways you can accomplish this. Add the following into Playgrounds:
![](https://epubservercos.yuewen.com/2E52D1/19470383901517806/epubprivate/OEBPS/Images/84cd802d-4b8b-4650-9d0a-23a4605930a9.png?sign=1739297653-LZvP3pXQ5RWsGejSIUjYEzAbMjPXyrYk-0-7f7cb70855c30da7ee87e1ebfe1396b5)
Both of these options do the same thing, but option #2 is in shorthand. The preferred way is to use option #2, which is += (addition assignment operator) and −= (subtraction assignment operator), but the choice is yours.