Why init(rawValue:) not callable for some enums?

319 Views Asked by At

Anyone know why this works in a playground, but in a normal source files, gives this error: /Incorrect argument label in call (have 'rawValue:', expected 'name:') Maybe it's a bug.

enum Foo : Int {
    case A, B, C

    init?(name:String) {
        switch name {
        case "A": self = .A
        case "B": self = .B
        case "C": self = .C
        default: return nil
        }
    }
}

let foo2 = Foo(rawValue:2)!

Edit: I've noticed it works fine or Mac OS. I'm only seeing this if it's compiling for iOS.

0

There are 0 best solutions below