简体   繁体   English

为什么我不能在快速操场上创建功能?

[英]Why can't I create func in swift playground?

I tried here http://swift-lang.org/tryswift/ 我在这里尝试过http://swift-lang.org/tryswift/

func sayHello(personName: String) -> String {
    let greeting = "Hello, " + personName + "!"
    return greeting
}

error message : 错误信息 :

Could not compile SwiftScript source: line 3:14: unexpected token: ( 无法编译SwiftScript源代码:行3:14:意外令牌:(

You're using the wrong Swift language – the website/online interpreter you're linking to is the site of the Swift Parallel Programming language, which has nothing to do with Apple's Swift language. 您使用了错误的Swift语言–您链接到的网站/在线解释器是Swift并行编程语言的站点,与Apple的Swift语言无关。

Your code works in Xcode. 您的代码在Xcode中有效。

http://swift-lang.org/tryswift/ doesn't look like it's anything to do with Apple Swift. http://swift-lang.org/tryswift/看起来与Apple Swift无关。 The "try Swift" page you're using is for Swift , not Swift . 您正在使用的“尝试Swift”页面用于Swift ,而不是Swift

Note that Apple's has the stylised swift in its logo heading downwards; 请注意,Apple的徽标向下具有风格化的快速 the parallel scripting language Swift is heading upwards :) Swift的并行脚本语言正在向前进:)

To try Apple's Swift in a similar way, you'll need the Xcode 6 beta and a "playground" file. 要以类似方式尝试Apple的Swift,您需要Xcode 6 Beta和一个“游乐场”文件。

That is a whole different Swift language which has been existing for a while. 那是一种完全不同的Swift语言,已经存在了一段时间。

The playground for Apple's Swift is available as a Desktop application only at the moment. Apple的Swift游乐场目前仅作为桌面应用程序可用。 Follow the links from here - https://developer.apple.com/swift/ 请点击此处的链接-https: //developer.apple.com/swift/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM