title: Swift: "Value of optional type '(Int, Int)?' not unwrapped; did you mean to use '!' or '?'?
body: <pre><code>class Game {
      var board: [[Int]]!
      var turns: Int!
      let coordinates = [1:(0,0), 2:(0,1), 3:(0,2), 4:(1,0), 5:(1,1), 6:(1,2), 7:(2,0), 8:(2,1), 9:(2,2)]
  
      init() {
          self.reset()
      }
  
      func reset() {
          self.board = [[0,0,0],[0,0,0],[0,0,0]]
          self.turns = 0
      }
  
      func moveByPlayer(player: Int, space: Int) {
          let spaceDictionary = [1:(0,0), 2:(0,1), 3:(0,2), 4:(1,0), 5:(1,1), 6:(1,2), 7:(2,0), 8:(2,1), 9:(2,2)]
          if let spaceTuple = spaceDictionary[space] {
              if self.board[spaceTuple.0][spaceTuple.1] == 0 {
                  self.board[spaceTuple.0][spaceTuple.1] = player
              }
          }
          print(self.board)
          self.turns = self.turns + 1
      }
  
      func checkForWin(space: Int) {
          let lines = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7]]
          for index in 0..&lt;lines.count {
              let x = self.coordinates[lines[index][0]]
              let y = self.coordinates[lines[index][1]]
              let z = self.coordinates[lines[index][2]]
              **if(self.board[x.0][x.1] != 0 &amp;&amp; self.board[x.0][x.1] == self.board[y.0][y.1] &amp;&amp; self.board[x.0][x.1] == self.board[z.0][z.1]){
                  return self.board[x.0][x.1]**
              }
          }
      }
  }
  </code></pre>
  
  <p>I am getting an error stating:</p>
  
  <blockquote>
    <p>"Value of optional type (Int, Int)? not unwrapped"</p>
  </blockquote>
  
  <p>where the code is supposed to be bolded but didn't format. I have a very similar implementation of an "unwrapped" dictionary in the previous function implementation but do not get the error. I am new to learning how Swift works. Can someone educate more on type casting and unwrapping of optionals in this context?</p>