jweinst1
7/12/2016 - 9:13 PM

enum with computed values swift

enum with computed values swift

//playground to test automata

enum dualStorage {
    case A(int:Int, string:String)
    
    init(int:Int, string:String){
        self = dualStorage.A(int: int, string: string)
    }
    //computed property for the int
    var int:Int {
        switch self {
        case .A(let int, _):
            return int
        }
    }
    //computed property for the string
    var string:String {
        switch self {
        case .A(_, let string):
            return string
        }
    }
    
}