当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Swift Int64 !=(_:_:)用法及代码示例


操作符

!=(_:_:)

返回一个布尔值,指示两个给定值是否不相等。

声明

static func != <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger

参数

lhs

要比较的整数。

rhs

另一个要比较的整数。

详述

您可以使用 not-equal-to 运算符 (!= ) 检查任何 BinaryInteger 类型的实例的不等式。例如,您可以测试字符串的 UTF-8 编码中的第一个 UInt8 值是否不等于其 Unicode 标量视图中的第一个 UInt32 值:


let gameName = "Red Light, Green Light"
if let firstUTF8 = gameName.utf8.first,
    let firstScalar = gameName.unicodeScalars.first?.value {
    print("First code values are different: \(firstUTF8 != firstScalar)")
}
// Prints "First code values are different: false"

可用版本

iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+

相关用法


注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Int64 !=(_:_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。