Created
October 19, 2016 12:38
-
-
Save aimak/ce34ebcd0750c48be211679780945087 to your computer and use it in GitHub Desktop.
optional init in Enum in Swift 2.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Origin { | |
case Foo | |
case Bar | |
init?(value : String) { | |
return .Foo | |
} | |
} |
Why don't you use:
enum Origin: String
and use the free initializer with the rawValue
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
return .Foo
does not compile :'nil' is the only return value permitted in an initializer