在Swift

时间:2019-07-17 09:06:12

标签: ios swift

如何使用for循环的值。这是示例代码。我可以返回所有名称吗?

func getResult() -> String {
    var x = ""
    let names = ["Arthur", "Zaphod", "Trillian", "Ford", "Marvin"]
    for name in names {
        x = name
    }
    return x
}

这是另一个示例代码

func getResults() -> String {
        var row = ""
        let exerciseType = try! self.database.prepare(self.exerciseTable)
        for types in exerciseType {
            row = types[self.type]
        }
        return row
    }

0 个答案:

没有答案