&/
和 &%
是否已从 Swift 2.0 中删除或语法是否已更改?
以下似乎在 Swift 1.2 中有效:
var divByZero: Int8 = 100 &/ aZero
var remainderDivByZero: Int8 = 100 &% aZero
我看过语言指南 Advanced Operations部分,我没有看到对这些操作的任何引用。我似乎找不到 Apple 的发行说明,其中包含从 1.2 到 2.0 的详细更改列表。
最佳答案
Revision history 2015-04-08其中:
Updated for Swift 1.2.
Removed the overflow division (&/) and overflow remainder (&%) operators from Overflow Operators.
在包含 Swift 1.1
之前似乎一直有效
release notes for Xcode 6.3 and Swift 1.2包括
The &/ and &% operators were removed, to simplify the language and improve consistency. Unlike the &+, &-, and &* operators, these operators did not provide two’s-complement arithmetic behavior; they provided special case behavior for division, remainder by zero, and Int.min/-1. These tests should be written explicitly in the code as comparisons if needed. (17926954).
关于swift - &/and &% 从 Swift 语言中移除了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34483606/