0

I am reading swift 2.1 iBook about enumeration

The example :

enum CompassPoint: String {
  case North, South, East, West
}

gives me

<stdin>:3:8: error: enum cases require explicit raw values when the raw type is not integer literal convertible
case North, South, East, West

demo

I am not sure if documentation is outdated or some issue with compiler

1 Answer 1

1

The error comes from the online compiler you're using because it's in Swift 1.2 by default and you're using Swift 2 code.

There's a "Swift 1.2" button in the lower right corner of the site page, change it to "Swift 2 (beta)" and the error will disappear.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.