title: Iterating Through a Dictionary in Swift
body: <p>I am a little confused on the answer that Xcode is giving me to this experiment in the Swift Programming Language Guide:</p>
  
  <pre><code>// Use a for-in to iterate through a dictionary (experiment)
  
  let interestingNumbers = [
      "Prime": [2, 3, 5, 7, 11, 13],
      "Fibonacci": [1, 1, 2, 3, 5, 8],
      "Square": [1, 4, 9, 16, 25]
  ]
  var largest = 0
  for (kind, numbers) in interestingNumbers {
      for number in numbers {
          if number &gt; largest {
              largest = number
          }
      }
  }
  largest
  </code></pre>
  
  <p>I understand that as the dictionary is being transversed, the largest number is being set to the variable, <code>largest</code>. However, I am confused as to why Xcode is saying that <code>largest</code> is being set 5 times, or 1 time, or 3 times, depending on each test. </p>
  
  <p>When looking through the code, I see that it should be set 6 times in "Prime" alone (2, 3, 5, 7, 11, 13). Then it should skip over any numbers in "Fibonacci" since those are all less than the largest, which is currently set to 13 from "Prime". Then, it should be set to 16, and finally 25 in "Square", yielding a total of 8 times. </p>
  
  <p>Am I missing something entirely obvious? </p>