【问题标题】:Is it possible to find the index of an tuple in an array? [duplicate]是否可以在数组中找到元组的索引? [复制]
【发布时间】:2017-08-09 07:45:12
【问题描述】:
Index(of: element)

不适用于元组,有没有办法找到元组的索引?

【问题讨论】:

标签: arrays swift


【解决方案1】:

在 where 子句中使用索引,这里是一个包含 2 个成员的元组的示例

let index = array.index {
    $0 == element.0 && $1 == element.1
}

【讨论】:

    猜你喜欢
    • 2013-07-19
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-13
    • 1970-01-01
    • 2011-12-02
    相关资源
    最近更新 更多