在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
所以在目前Swift5的版本中,只能用+=1和-=1来进行递增和递减了 Use of unresolved operator '++'; did you mean '+= 1'? 这是Swift的新功能(我就这么弄,怎么了) 2.Their expressive advantage is minimal - x++ is not much shorter than x += 1. 3.Swift already deviates from C in that the =, += and other assignment-like operations returns Void (for a number of reasons). These operators are inconsistent with that model. 4.Swift has powerful features that eliminate many of the common reasons you'd use ++i in a C-style for loop in other languages, so these are relatively infrequently used in well-written Swift code. These features include the for-in loop, ranges, enumerate, map, etc. 5.Code that actually uses the result value of these operators is often confusing and subtle to a reader/maintainer of code. They encourage "overly tricky" code which may be cute, but difficult to understand. 6.While Swift has well defined order of evaluation, any code that depended on it (like foo(++a, a++)) would be undesirable even if it was well-defined. 7.These operators are applicable to relatively few types: integer and floating point scalars, and iterator-like concepts. They do not apply to complex numbers, matrices, etc. Finally, these fail the metric of "if we didn't already have these, would we add them to Swift 3?" |
请发表评论