title: Enum variables in Swift?
body: <p>I would like to associate multiple values with an enum value, in a generic way.</p>
  
  <p>This can be done in Java:</p>
  
  <pre><code>enum Test {
  
      A("test", 2);
  
      final String var1;
      final int var2;
  
      Test (String var1, int var2) {
          this.var1 = var1;
          this.var2 = var2;
      }
  }
  
   public static void main(String []args){
      Test test = Test.A;
      System.out.println(test.var1);
   }
  </code></pre>
  
  <p>But it looks like it's not possible with Swift? So far, according to <a href="https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html" rel="noreferrer">docs</a>, there are:</p>
  
  <ol>
  <li><p>Associated values. Example (from <a href="https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html" rel="noreferrer">docs</a>):</p>
  
  <pre><code>enum Barcode {
      case UPCA(Int, Int, Int, Int)
      case QRCode(String)
  }
  </code></pre>
  
  <p>But this is not what I need.</p></li>
  <li><p>Raw value. Example (from <a href="https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html" rel="noreferrer">docs</a>):</p>
  
  <pre><code>enum ASCIIControlCharacter: Character {
      case Tab = "\t"
      case LineFeed = "\n"
      case CarriageReturn = "\r"
  }
  </code></pre>
  
  <p>This would be what I need, but it can have only one value!</p></li>
  </ol>
  
  <p>Is there an elegant solution for this...? Seems like a language design decision, as it would conflict with the associated values concept, at least in the current form. I know I could use e.g. a dictionary to map the enum values to the rest, but really missing to do this in one safe step, like in Java.</p>