2017-08-09 85 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 
} 
相关问题