Swift: Implicit Return Not Compiling?

给你一囗甜甜゛ 提交于 2021-01-27 10:47:34

问题


I was checking out the Swift documentation on implicit returns. Consider this function from the docs:

func greeting(for person: String) -> String {
    "Hello, " + person + "!"
}

When I copy and paste it into xCode I get an error: "Missing return in a function expected to return 'String' "

My swift version is set to 5.0 in build settings.

Honestly don't know if I am missing something obvious here, or if there is a problem with my other xCode build settings? Ideas?

来源:https://stackoverflow.com/questions/56812483/swift-implicit-return-not-compiling

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!