I have an enum
:
public enum PersonType:String {
case Cool = \"cool\"
case Nice = \"rude\"
case
Another approach that works in Swift 3 (maybe 2, don't know):
enum PersonType: String {
case cool = "cool"
case nice = "nice"
case soLazy = "so-lazy"
case other
}
let person = PersonType(rawValue: "funny") ?? .other
The person variable is of type PersonType.other in this case.
The downside to this is that you don't know the raw string value of the .other case.