I want to do this...
let myInt = E.i(420)
let myString = E.s("Crook")
...with this...
enum E {
case i(Int?)
case s(String?)
func i() -> Int? {
// How do I implement?
}
func s() -> String? {
// How do I implement?
}
}
...so I can do this...
let theInt = myInt.i()
let theString = myDouble.s()
...or even better, do this...
let betterInt = myInt.i
let betterString = myString.s
...or if I want to be in heaven...
let i = myInt // based on associated value return typed value as Int or nil
let i: Int = myInt // convert it automatically and return Int or nil
let s = myString // based on associated value return typed value as String or nil
let s: String = myString // convert it automatically and return String or nil