我正在阅读关于枚举的swift 2.1 iBook
示例:
enum CompassPoint: String {
case North, South, East, West
}
给了我
<stdin>:3:8: error: enum cases require explicit raw values when the raw type is not integer literal convertible
case North, South, East, West
我不确定文档是否已过时或编译器存在问题
答案 0 :(得分:1)
错误来自您使用的online compiler,因为默认情况下它位于Swift 1.2中并且您使用的是Swift 2代码。
有一个&#34; Swift 1.2&#34;网站页面右下角的按钮,将其更改为&#34; Swift 2(测试版)&#34;并且错误将消失。