Conversion operator in swift
问题 Is it possible to write custom conversion (casting) operator in swift ? Especially I'm looking for enums conversion, ex: enum MyEnum : Int { case Case1 = 0 case Case2 func __conversion() -> String { // doesn't work since Swift 1.0 switch self { case Case1: return "Case 1" case Case2: return "Case 2" } } } let enumStr: String = MyEnum.Case1 Of course, I can convert to String with explicit method, but I would like to have implicit mechanism. 回答1: Disclaimer/TL;DR! This answer pertains to the