2017-08-09 81 views
0
Index(of: element) 

不適用於元組,有沒有辦法找到一個元組的索引?是否可以在數組中找到元組的索引?

+0

讓arrayOfTuples = [(1, 「你好」),(101, 「世界」),(200,「堆溢出「)] let firstTuple = arrayOfTuples [0] .1 //您好,通過使用https://developer.apple.com/documentation/swift/array/1540606-subscript –

回答

0

使用索引與where子句,這裏的元組的樣品用2名成員

let index = array.index { 
    $0 == element.0 && $1 == element.1 
} 
相關問題