title: Dictionary with Multiple Keys for a Single Value - Swift
body: <p>I'm attempting to create an application that maps English letters to various RNA codons (sequences of A, C, U, or G in groups of 3), according to a predetermined mapping.</p>
  
  <p>To convert from English to RNA, the dictionary looks like this:</p>
  
  <pre><code>var englishTomRNA: [Character: [String]] = ["A": ["UUU", "UAC"],
                                              "Q": ["UUA"],
                                              "S": ["UCU", "UCC", "UCA"]]
  </code></pre>
  
  <p>etc.</p>
  
  <p>As you can see, there are multiple values for any given English character (representing the biological characteristic of a polygenetic genotype), of which I have no issue converting to.</p>
  
  <p>What I do have an issue implementing, however, is the dictionary to covert the other way. I originally used <code>switch: case</code> statements like so:</p>
  
  <pre><code>    for codon in preEnglishInputString {
          switch codon {
              case "UUU", "UAC":               inEnglish.append("A")
              case "UUA":                      inEnglish.append("Q")
              case "UCU", "UCC", "UCA", "UCG": inEnglish.append("S")
          }
      }
  </code></pre>
  
  <p>However, now I wish to convert the RNA -> English conversion function to use dictionaries to be more inline with this implementation. </p>
  
  <p>I cannot figure out how to have multiple keys for a single value (the reverse of having multiple values for a single key, as used above.)</p>
  
  <p>The following, when attempted, doesn't work:</p>
  
  <pre><code>let mRNAtoEnglish: [[String] : Character] =
                                              [["UUU", "UAC"]       : "A",
                                              ["UUA", "UUG"]        : "Q",
                                              ["UCU", "UCC", "UCA"] : "S"]
  </code></pre>
  
  <p>with the compiler yelling <code>Type [String] does not conform to protocol 'Hashable'</code> </p>
  
  <p>Am I simply using the wrong data structure, or is there some syntax that i'm not aware of? (I'm fairly new to Swift)</p>
  
  <p>Thanks!</p>