在Swift4的参考手册中。 https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Functions.html
我已经看过参数标签的教程和iOS用法。
使用这些参数或参数标签的价值是什么?
func greet(person: String, from hometown: String) -> String {
return "Hello \(person)! Glad you could visit from \(hometown)."
}
print(greet(person: "Bill", from: "Cupertino"))
上面,在greet函数中声明“from”的值是多少?
func greet(person: String, hometown: String) -> String {
return "Hello \(person)! Glad you could visit from \(hometown)."
}
print(greet(person: "Bill", hometown: "Cupertino"))
答案 0 :(得分:0)
我建议您阅读Swift API Design Guidelines
最终,只有设计师/社区的意见才是他们希望事情发挥作用的方式。一般的推理是它在使用时提高了清晰度和简洁性,并且感觉更像是句子。 “问候比尔故乡库比蒂诺”vs“来自库比蒂诺的招呼人比尔”