title: Unable to assign class objects to dictionary member of another class object in Swift 3
body: <p>I have a class ChessSquare with its own attributes and methods. I have another class ChessBoard, which has an attribute of dictionary type.</p>
  
  <pre><code>class ChessBoard {
      var squares: [ Int : ChessSquare ] = [:]
      .....
  </code></pre>
  
  <p>One of the methods of the ChessBoard class builds the chessSquare object and assigns it to chessBoard object as below.</p>
  
  <pre><code>self.squares[squareName] = chessSquare
  </code></pre>
  
  <p><strong><em>Before Swift3 this code was working fine.</em></strong> After upgrading to Swift3 the assignment stopped working. </p>
  
  <p>Using breakpoints I see that chessSquare objects are built as expected. squareName variable has the expected value. The "self", which is the chessBoard object has proper initial values. But the dictionary assignment gets skipped without any error in the above mentioned code.</p>
  
  <p>Is this anything related to Swift3. I browsed and could not get specific solution to my case.</p>
  
  <hr>
  
  <p>Adding more code for clarity.</p>
  
  <pre><code>class ChessSquare {
      let squareColor: UIColor
      let squareShade: Int
      let squareName: Int
      let squareSize: CGSize
      let minXY: CGPoint
      let maxXY: CGPoint
      let squareOrigin: CGPoint
      var hasPiece = false
      weak var chessPiece: ChessPiece?
      let squareSprite: SKSpriteNode
      let squareType: SquareType
      //more data members
  
      init(squareColor: UIColor, squareShade: Int, squareName: Int, squareSize: CGSize, minXY: CGPoint, maxXY: CGPoint, squareOrigin: CGPoint, squareSprite: SKSpriteNode, squareType: SquareType) {
          self.squareColor = squareColor
          self.squareShade = squareShade
          self.squareName = squareName
          self.squareSize = squareSize
          self.minXY = minXY
          self.maxXY = maxXY
          self.squareOrigin = squareOrigin
          self.squareSprite = squareSprite
          self.squareType = squareType
      }
  
      //more methods
  
  }
  
  class ChessBoard {
      var squares: [ Int : ChessSquare ] = [:]
      var byteBoard: [UInt8] = [UInt8](repeating: UInt8(0), count: 66)
      var byteBoardHashVal: Int = 0
      // [ byteBoardHashVal : ((byteBoard, evalnVal), repCnt) ]
      var byteBoards: [Int : (([UInt8],Double?), Int)] = [:]
      var TT: [Int : Double] = [:]
      var TTReuseCount = 0
      var whitePawnlessFileByte: UInt8 = 255
      var blackPawnlessFileByte: UInt8 = 255
  
      var maxXY: CGPoint = CGPoint()
      var minXY: CGPoint = CGPoint()
  
      var oldTouchedSquare: ChessSquare?
  
      init() {
          squares = [:]
          byteBoard = [UInt8](repeating: UInt8(0), count: 66)
          byteBoardHashVal = 0
          byteBoards = [:]
          TT = [:]
          TTReuseCount = 0
          whitePawnlessFileByte = 255
          blackPawnlessFileByte = 255
  
      }
  
      func drawFlippedChessBoard(_ view: SKView, scene: GameScene) {
          ....
          ....
          for row in 0..&lt;8 {
              for col in 0..&lt;8 {
                  let squareName = row * 8 + col
  
                  ....
  
                  let chessSquare = ChessSquare(squareColor: currentColor, squareShade: squareShade, squareName: squareName, squareSize: squareSize, minXY: minXY, maxXY: maxXY, squareOrigin: squareOrigin, squareSprite: squareSprite, squareType: squareType)
  
                  ....
  
                  self.squares[squareName] = chessSquare
  
                  ....
              }
              ....
          }
          ....
      }
  
      //more methods
  
  }
  </code></pre>