用法一
操作符
==(_:
==(_:_:)
返回一個布爾值,指示兩個元組的對應分量是否相等。
聲明
func == <A, B, C, D, E>(lhs: (A, B, C, D, E), rhs: (A, B, C, D, E)) -> Bool where A : Equatable, B : Equatable, C : Equatable, D : Equatable, E : Equatable
參數
lhs
Equatable
元素的元組。rhs
另一個與
lhs
類型相同的元素元組。
詳述
為了讓兩個元組比較相等,每對對應的組件必須相等。以下示例比較了由 5 個組件組成的元組:
let a = ("a", 1, 2, 3, 4)
let b = ("a", 1, 2, 3, 4)
print(a == b)
// Prints "true"
let c = ("a", 1, 2, 3, 5)
print(a == c)
// Prints "false"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
用法二
操作符
==(_:
==(_:_:)
返回一個布爾值,指示兩個元組的對應分量是否相等。
聲明
func == <A, B, C, D, E, F>(lhs: (A, B, C, D, E, F), rhs: (A, B, C, D, E, F)) -> Bool where A : Equatable, B : Equatable, C : Equatable, D : Equatable, E : Equatable, F : Equatable
參數
lhs
Equatable
元素的元組。rhs
另一個與
lhs
類型相同的元素元組。
詳述
為了讓兩個元組比較相等,每對對應的組件必須相等。以下示例比較了由 6 個組件組成的元組:
let a = ("a", 1, 2, 3, 4, 5)
let b = ("a", 1, 2, 3, 4, 5)
print(a == b)
// Prints "true"
let c = ("a", 1, 2, 3, 4, 6)
print(a == c)
// Prints "false"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
用法三
操作符
==(_:
==(_:_:)
返回一個布爾值,指示兩個元組的對應分量是否相等。
聲明
func == <A, B>(lhs: (A, B), rhs: (A, B)) -> Bool where A : Equatable, B : Equatable
參數
lhs
Equatable
元素的元組。rhs
另一個與
lhs
類型相同的元素元組。
詳述
為了讓兩個元組比較相等,每對對應的組件必須相等。以下示例比較了由 2 個組件組成的元組:
let a = ("a", 1)
let b = ("a", 1)
print(a == b)
// Prints "true"
let c = ("a", 2)
print(a == c)
// Prints "false"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
用法四
操作符
==(_:
==(_:_:)
返回一個布爾值,指示兩個元組的對應分量是否相等。
聲明
func == <A, B, C, D>(lhs: (A, B, C, D), rhs: (A, B, C, D)) -> Bool where A : Equatable, B : Equatable, C : Equatable, D : Equatable
參數
lhs
Equatable
元素的元組。rhs
另一個與
lhs
類型相同的元素元組。
詳述
為了讓兩個元組比較相等,每對對應的組件必須相等。以下示例比較了由 4 個組件組成的元組:
let a = ("a", 1, 2, 3)
let b = ("a", 1, 2, 3)
print(a == b)
// Prints "true"
let c = ("a", 1, 2, 4)
print(a == c)
// Prints "false"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
用法五
操作符
==(_:
==(_:_:)
返回一個布爾值,指示兩個元組的對應分量是否相等。
聲明
func == <A, B, C>(lhs: (A, B, C), rhs: (A, B, C)) -> Bool where A : Equatable, B : Equatable, C : Equatable
參數
lhs
Equatable
元素的元組。rhs
另一個與
lhs
類型相同的元素元組。
詳述
為了讓兩個元組比較相等,每對對應的組件必須相等。以下示例比較了由 3 個組件組成的元組:
let a = ("a", 1, 2)
let b = ("a", 1, 2)
print(a == b)
// Prints "true"
let c = ("a", 1, 3)
print(a == c)
// Prints "false"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相關用法
- Swift ===(_:_:)用法及代碼示例
- Swift KeyValuePairs flatMap(_:)用法及代碼示例
- Swift String.UTF8View first用法及代碼示例
- Swift Result.Publisher zip(_:_:_:)用法及代碼示例
- Swift Optional.Publisher reduce(_:_:)用法及代碼示例
- Swift Int8 ~(_:)用法及代碼示例
- Swift SetAlgebra isStrictSubset(of:)用法及代碼示例
- Swift UInt +(_:)用法及代碼示例
- Swift Array enumerated()用法及代碼示例
- Swift FlattenSequence prefix(_:)用法及代碼示例
- Swift Slice endIndex用法及代碼示例
- Swift LazySequence split(maxSplits:omittingEmptySubsequences:whereSeparator:)用法及代碼示例
- Swift MutableCollection partition(by:)用法及代碼示例
- Swift ReversedCollection min(by:)用法及代碼示例
- Swift RandomNumberGenerator用法及代碼示例
- Swift Dictionary.Keys shuffled()用法及代碼示例
- Swift AnySequence elementsEqual(_:)用法及代碼示例
- Swift UInt &<<(_:_:)用法及代碼示例
- Swift Optional.Publisher tryDrop(while:)用法及代碼示例
- Swift DefaultIndices endIndex用法及代碼示例
- Swift Substring.UnicodeScalarView insert(contentsOf:at:)用法及代碼示例
- Swift LazyFilterSequence dropFirst(_:)用法及代碼示例
- Swift LazySequence suffix(from:)用法及代碼示例
- Swift ArraySlice starts(with:)用法及代碼示例
- Swift Int16.Words max()用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 ==(_:_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。