swift-playground – 元素序列,但“join is unavailable:调用’joinWithSeparator()’”错误

前端之家收集整理的这篇文章主要介绍了swift-playground – 元素序列,但“join is unavailable:调用’joinWithSeparator()’”错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试在操场上运行时,为什么我会在第16行(下面的最后一行)收到错误“join is unavailable:call the joinWithSeparator()”?而且,我该如何解决它?
class Person {
    var firstName: String?
    var lastName: String?
    let gender = "female"

    func fullName() -> String {
        var parts: [String] = []

        if let firstName = self.firstName {
            parts += [firstName]
        }

        if let lastName = self.lastName {
            parts += [lastName]
        }
        return " ".join(parts)
    }
}
错误消息告诉您问题所在,并告诉您如何解决问题.阅读错误信息!做错误信息说的!
return parts.joinWithSeparator(" ")

猜你在找的Swift相关文章