gpt4 book ai didi

swift-playground - 元素序列,但 "join is unavailable: call the ' joinWithSeparator( )'"错误

转载 作者:行者123 更新时间:2023-12-04 07:26:45 24 4
gpt4 key购买 nike

当我尝试在操场上运行它时,为什么会在第 16 行(下面的最后一行)收到错误“加入不可用:调用 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-playground - 元素序列,但 "join is unavailable: call the ' joinWithSeparator( )'"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34688387/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com