操作符
==(_:
==(_:_:)
返回一个布尔值,指示两个给定值是否相等。
声明
static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger
参数
lhs
要比较的整数。
rhs
另一个要比较的整数。
详述
您可以使用等于运算符 (==
) 检查任何 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 equal: \(firstUTF8 == firstScalar)")
}
// Prints "First code values are equal: true"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相关用法
- Swift UInt16 &*=(_:_:)用法及代码示例
- Swift UInt16 leadingZeroBitCount用法及代码示例
- Swift UInt16 %=(_:_:)用法及代码示例
- Swift UInt16 ...(_:)用法及代码示例
- Swift UInt16 &<<(_:_:)用法及代码示例
- Swift UInt16 -(_:_:)用法及代码示例
- Swift UInt16 <<=(_:_:)用法及代码示例
- Swift UInt16 &-(_:_:)用法及代码示例
- Swift UInt16 random(in:)用法及代码示例
- Swift UInt16 ...(_:_:)用法及代码示例
- Swift UInt16 init(_:)用法及代码示例
- Swift UInt16 quotientAndRemainder(dividingBy:)用法及代码示例
- Swift UInt16 init(clamping:)用法及代码示例
- Swift UInt16 /(_:_:)用法及代码示例
- Swift UInt16 init(integerLiteral:)用法及代码示例
- Swift UInt16 *(_:_:)用法及代码示例
- Swift UInt16 &+(_:_:)用法及代码示例
- Swift UInt16 ^(_:_:)用法及代码示例
- Swift UInt16 ..<(_:_:)用法及代码示例
- Swift UInt16 ^=(_:_:)用法及代码示例
- Swift UInt16 &<<=(_:_:)用法及代码示例
- Swift UInt16 %(_:_:)用法及代码示例
- Swift UInt16 &>>(_:_:)用法及代码示例
- Swift UInt16 <<(_:_:)用法及代码示例
- Swift UInt16 +=(_:_:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 UInt16 ==(_:_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。