swift 数组中元素的第一个索引

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 数组中元素的第一个索引相关的知识,希望对你有一定的参考价值。

var students = ["Ben", "Ivy", "Jordell", "Maxime"]
if let i = students.firstIndex(of: "Maxime") {
    students[i] = "Max"
print(students)
// Prints "["Ben", "Ivy", "Jordell", "Max"]"

以上是关于swift 数组中元素的第一个索引的主要内容,如果未能解决你的问题,请参考以下文章