title: How to simplify Swift Enum custom init
body: <p>I've crated an Enum with String type. It has two init methods. One is default init method with rawValue and another one is custom init method with intValue. I've written it like this. Is there any simple way to not to use two switch cases?</p>
  
  <pre><code>enum Roman: String {
      case I,V,X,L,C,D,M
  
      var intValue: Int {
          switch self {
          case .I:
              return 1
          //...
          }
      }
      init?(intValue: Int) {
          switch intValue {
          case 1:
              self = .I
          //...
          default:
              return nil
          }
      }
  }
  
      //Roman to Int
      let number = "XXI".reversed()
                      .map { Roman(rawValue: String($0))?.intValue ?? 0 }
                      .reduce((total: 0, max: 0)) { result, value in
                          let newTotal = result.total + (value &lt; result.max ? -value : value)
                          return (newTotal, max(result.max, value))
                      }.total
  </code></pre>