swift - &/and &% 从 Swift 语言中移除了吗?

标签 swift swift2 operators

&/&% 是否已从 Swift 2.0 中删除或语法是否已更改?

以下似乎在 Swift 1.2 中有效:

var divByZero: Int8 = 100 &/ aZero
var remainderDivByZero: Int8 = 100 &% aZero

来自learn-swift playground

我看过语言指南 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/

相关文章:

ios - 使用编程约束在 View 中创建 2 个 View

ios - iOS10 的 Podspec Linting 问题

c - 预处理器运算符 "defined"的优先级?

c++ - 进行小于比较还是小于或等于比较更有效?

ios - 显示等待 View ,直到正在进行图像过滤

swift - TPPDF 表对齐

ios - 如何在核心数据中找到属性的索引

ruby - 可以覆盖/实现的 ruby​​ 运算符列表

swift - 如何在 Swift 中设计一个通用的观察者模式协议(protocol)?

ios - Swift 2 无代表