如果我有一个带有原始Integer值的枚举:
enum City: Int {
case Melbourne = 1, Chelyabinsk, Bursa
}
let city = City.Melbourne
Run Code Online (Sandbox Code Playgroud)
如何将city值转换为字符串Melbourne?这种类型的名称内省是否可用于该语言?
像(这段代码不起作用):
println("Your city is \(city.magicFunction)")
> Your city is Melbourne
Run Code Online (Sandbox Code Playgroud)